Skip to content

Commit 7f69c19

Browse files
peter279kajaxray
authored andcommitted
Test enhancement (#6)
- Set multiple PHPUnit versions to support different PHP versions. - Set the nightly test and accept this can be failed in Travis CI build. - Add the php-7.2 test in Travis CI build. - Use the class-based PHPUnit namespace to support the stable PHPUnit version. - Add more tests. Thanks to @peter279k 👍
1 parent 923a7f9 commit 7f69c19

File tree

5 files changed

+62
-4
lines changed

5 files changed

+62
-4
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ language: php
22
php:
33
- 5.6
44
- 7.1
5+
- 7.2
6+
- nightly
57

8+
matrix:
9+
allow_failures:
10+
- php: nightly
611
script:
712
- composer install --prefer-dist --no-interaction
813
- mkdir -p build/logs

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
},
2727
"require-dev": {
2828
"satooshi/php-coveralls": "v2.*",
29-
"phpunit/phpunit": "5.7.5"
29+
"phpunit/phpunit": "^5.7 || ^6.5"
3030
}
3131
}

tests/Ajaxray/PHPWatermark/Tests/CommandBuilders/ImageCommandBuilderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
use Ajaxray\PHPWatermark\CommandBuilders\ImageCommandBuilder;
1313
use Ajaxray\PHPWatermark\Watermark;
14+
use PHPUnit\Framework\TestCase;
1415

15-
class ImageCommandBuilderTest extends \PHPUnit_Framework_TestCase
16+
class ImageCommandBuilderTest extends TestCase
1617
{
1718
protected $options = [
1819
'position' => 'Center',

tests/Ajaxray/PHPWatermark/Tests/CommandBuilders/PDFCommandBuilderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
use Ajaxray\PHPWatermark\CommandBuilders\PDFCommandBuilder;
1313
use Ajaxray\PHPWatermark\Watermark;
14+
use PHPUnit\Framework\TestCase;
1415

15-
class PDFCommandBuilderTest extends \PHPUnit_Framework_TestCase
16+
class PDFCommandBuilderTest extends TestCase
1617
{
1718
protected $options = [
1819
'position' => 'Center',

tests/Ajaxray/PHPWatermark/Tests/WatermarkTest.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
use Ajaxray\PHPWatermark\CommandBuilders\PDFCommandBuilder;
1212
use Ajaxray\PHPWatermark\Watermark;
1313
use Ajaxray\TestUtils\NonPublicAccess;
14+
use PHPUnit\Framework\TestCase;
1415

15-
class WatermarkTest extends \PHPUnit_Framework_TestCase
16+
class WatermarkTest extends TestCase
1617
{
1718
use NonPublicAccess;
1819

@@ -213,6 +214,56 @@ public function testCommandReturnedIfDebugEnabled()
213214
$this->assertContains('path/to/logo.png', $command);
214215
}
215216

217+
public function testSetPositionOnPositionList()
218+
{
219+
$watermark = new Watermark('path/to/file.jpg');
220+
$setPosition = $watermark->setPosition(Watermark::POSITION_CENTER);
221+
$options = $this->invokeProperty($watermark, 'options');
222+
223+
$this->assertInstanceOf(Watermark::class, $setPosition);
224+
$this->assertContains(Watermark::POSITION_CENTER, $options);
225+
}
226+
227+
public function testSetStyle()
228+
{
229+
$watermark = new Watermark('path/to/file.jpg');
230+
$setStyle = $watermark->setStyle(Watermark::STYLE_IMG_COLORLESS);
231+
$options = $this->invokeProperty($watermark, 'options');
232+
233+
$this->assertInstanceOf(Watermark::class, $setStyle);
234+
$this->assertContains(Watermark::STYLE_IMG_COLORLESS, $options);
235+
}
236+
237+
public function testSetTileSize()
238+
{
239+
$watermark = new Watermark('path/to/file.jpg');
240+
$setStyle = $watermark->setTileSize(200, 150);
241+
$options = $this->invokeProperty($watermark, 'options');
242+
243+
$this->assertInstanceOf(Watermark::class, $setStyle);
244+
$this->assertContains([200, 150], $options);
245+
}
246+
247+
public function testSetFont()
248+
{
249+
$watermark = new Watermark('path/to/file.jpg');
250+
$setFont = $watermark->setFont('Arial');
251+
$options = $this->invokeProperty($watermark, 'options');
252+
253+
$this->assertInstanceOf(Watermark::class, $setFont);
254+
$this->assertContains('Arial', $options);
255+
}
256+
257+
public function testSetFontSize()
258+
{
259+
$watermark = new Watermark('path/to/file.jpg');
260+
$setFontSize = $watermark->setFontSize(20);
261+
$options = $this->invokeProperty($watermark, 'options');
262+
263+
$this->assertInstanceOf(Watermark::class, $setFontSize);
264+
$this->assertContains(20, $options);
265+
}
266+
216267
}
217268

218269

0 commit comments

Comments
 (0)