Skip to content

Commit ba855e7

Browse files
committed
Add unit test for ImageWorkshop::initFromPath factory through HTTP
1 parent 56d364a commit ba855e7

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ matrix:
1212
- php: 7.0
1313

1414
before_script:
15+
- php -S localhost:8000 -t fixtures/ &> /dev/null &
1516
- composer self-update
1617
- composer install --prefer-source
1718

fixtures/sample1.jpg

96.3 KB
Loading

tests/ImageWorkshopTest.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class ImageWorkshopTest extends \PHPUnit_Framework_TestCase
2121
// ===================================================================================
2222

2323
const IMAGE_SAMPLE_PATH = '/Resources/images/sample1.jpg';
24-
const FONT_SAMPLE_PATH = '/Resources/fonts/arial.ttf';
24+
const FONT_SAMPLE_PATH = '/Resources/fonts/arial.ttf';
25+
const WEB_PATH = 'http://localhost:8000';
2526

2627
// Tests
2728
// ===================================================================================
@@ -46,6 +47,15 @@ public function testInitFromPath()
4647
$this->assertTrue(get_class($layer) === 'PHPImageWorkshop\Core\ImageWorkshopLayer', 'Expect $layer to be an ImageWorkshopLayer object');
4748

4849
// test 3
50+
51+
if (version_compare(PHP_VERSION, '5.4', '>=')) {
52+
$layer = ImageWorkshop::initFromPath(static::WEB_PATH.'/sample1.jpg');
53+
54+
$this->assertTrue(is_object($layer) === true, 'Expect $layer to be an object');
55+
$this->assertTrue(get_class($layer) === 'PHPImageWorkshop\Core\ImageWorkshopLayer', 'Expect $layer to be an ImageWorkshopLayer object');
56+
}
57+
58+
// test 4
4959

5060
$this->setExpectedException('PHPImageWorkshop\Exception\ImageWorkshopException', '', ImageWorkshop::ERROR_IMAGE_NOT_FOUND);
5161
$layer = ImageWorkshop::initFromPath('fakePath');

0 commit comments

Comments
 (0)