From 52b2d9d10ad278e378a62b89dbadceb589b51096 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 15:13:22 +0630 Subject: [PATCH 01/13] support laravel 6.0 --- .travis.yml | 7 +++--- composer.json | 10 ++++---- phpunit.xml | 3 +-- tests/testBaseOptions.php | 53 +++++++++++++++++++-------------------- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ac492e..79f5f5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,15 @@ language: php - + php: - 5.4 - 5.5 - 5.6 + - 7.2 - hhvm - + before_script: - composer self-update - composer install --prefer-source --no-interaction --dev - + # script: build.sh script: phpunit --configuration phpunit.xml --coverage-text \ No newline at end of file diff --git a/composer.json b/composer.json index a9933fd..b19e5e8 100644 --- a/composer.json +++ b/composer.json @@ -11,18 +11,18 @@ } ], "require": { - "php": ">=5.4.7", + "php": ">=5.4.7 || 7.2", "php-amqplib/php-amqplib": "2.*", - "illuminate/support": "5.*" + "illuminate/support": "5.* || 6.0" }, "require-dev": { - "phpunit/phpunit": "4.0.*", + "phpunit/phpunit": "4.0.* || ^7.5", "mockery/mockery": "dev-master" }, "autoload": { "psr-4": { "Mookofe\\Tail\\": "src/" } - }, + }, "minimum-stability": "stable" -} \ No newline at end of file +} diff --git a/phpunit.xml b/phpunit.xml index 96ea445..471fadb 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,8 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" - syntaxCheck="false"> + stopOnFailure="false"> ./tests/ diff --git a/tests/testBaseOptions.php b/tests/testBaseOptions.php index 932797e..9c0b5e4 100644 --- a/tests/testBaseOptions.php +++ b/tests/testBaseOptions.php @@ -2,38 +2,28 @@ use Mockery; use Mookofe\Tail\BaseOptions; +use PHPUnit\Framework\TestCase; /** * Test base option class * - * @author Victor Cruz + * @author Victor Cruz */ -class testBaseOptions extends \PHPUnit_Framework_TestCase +class testBaseOptions extends TestCase { - - protected $input; - - public function __construct() - { - $this->input = Mockery::mock('Illuminate\Config\Repository'); - - } - - public function tearDown() - { - Mockery::close(); - } - public function testValidateOptions() { - $options = array('queue_name' => 'this_queue'); - $baseOptions = new BaseOptions($this->input); + $input = Mockery::mock('Illuminate\Config\Repository'); + $options = array('queue_name' => 'this_queue'); + $baseOptions = new BaseOptions($input); $result = $baseOptions->validateOptions($options); //Asserts $this->assertInstanceOf('Mookofe\Tail\BaseOptions', $result); + + Mockery::close(); } /** @@ -41,36 +31,45 @@ public function testValidateOptions() */ public function testValidateOptionsInvalid() { + $input = Mockery::mock('Illuminate\Config\Repository'); + $options = array('invalid_field' => 'this_is_invalid_field'); - $baseOptions = new BaseOptions($this->input); + $baseOptions = new BaseOptions($input); + $result = $baseOptions->validateOptions($options); - $result = $baseOptions->validateOptions($options); + Mockery::close(); } public function testSetOptions() { - $options = array('queue_name' => 'this_queue'); - $baseOptions = new BaseOptions($this->input); + $input = Mockery::mock('Illuminate\Config\Repository'); + $options = array('queue_name' => 'this_queue'); + $baseOptions = new BaseOptions($input); $baseOptions->setOptions($options); - //Assertss + //Assertss $this->assertObjectHasAttribute('queue_name', $baseOptions); $this->assertEquals($baseOptions->queue_name, $options['queue_name']); + Mockery::close(); } public function testBuildConnectionOptions() { + + $input = Mockery::mock('Illuminate\Config\Repository'); //Mock Input object - $this->input->shouldReceive('get')->once()->andReturn('just_to_return'); - $this->input->shouldReceive('get')->once()->andReturn(array()); - + $input->shouldReceive('get')->once()->andReturn('just_to_return'); + $input->shouldReceive('get')->once()->andReturn(array()); + //Setup enviroment - $baseOptions = new BaseOptions($this->input); + $baseOptions = new BaseOptions($input); $options = $baseOptions->buildConnectionOptions(); //Asserts $this->assertInternalType('array', $options); $this->assertArrayHasKey('queue_name', $options); + + Mockery::close(); } } \ No newline at end of file From 7422b7aee12711f11a665538082f3d6dcefc7ecb Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 15:22:01 +0630 Subject: [PATCH 02/13] refactor of compatible for phpunit9 --- tests/testBaseOptions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/testBaseOptions.php b/tests/testBaseOptions.php index 9c0b5e4..7adf82c 100644 --- a/tests/testBaseOptions.php +++ b/tests/testBaseOptions.php @@ -37,6 +37,9 @@ public function testValidateOptionsInvalid() $baseOptions = new BaseOptions($input); $result = $baseOptions->validateOptions($options); + //Assert + $this->expectException($result); + Mockery::close(); } @@ -67,7 +70,7 @@ public function testBuildConnectionOptions() $options = $baseOptions->buildConnectionOptions(); //Asserts - $this->assertInternalType('array', $options); + $this->assertIsArray($options); $this->assertArrayHasKey('queue_name', $options); Mockery::close(); From 6ccf31417abd342bcbdf784294293eb0cf4f3672 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 15:25:33 +0630 Subject: [PATCH 03/13] refactor of compatible for phpunit9 --- tests/testBaseOptions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testBaseOptions.php b/tests/testBaseOptions.php index 7adf82c..fe8f837 100644 --- a/tests/testBaseOptions.php +++ b/tests/testBaseOptions.php @@ -27,7 +27,7 @@ public function testValidateOptions() } /** - * @expectedException Mookofe\Tail\Exceptions\InvalidOptionException + * ExpectedException Mookofe\Tail\Exceptions\InvalidOptionException */ public function testValidateOptionsInvalid() { From 26af7126cec1f4a44967b239b09ebc22389894ae Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 15:28:50 +0630 Subject: [PATCH 04/13] refactor of compatible for phpunit9 --- tests/testBaseOptions.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/testBaseOptions.php b/tests/testBaseOptions.php index fe8f837..ed852f8 100644 --- a/tests/testBaseOptions.php +++ b/tests/testBaseOptions.php @@ -27,7 +27,7 @@ public function testValidateOptions() } /** - * ExpectedException Mookofe\Tail\Exceptions\InvalidOptionException + * @expectedException Mookofe\Tail\Exceptions\InvalidOptionException */ public function testValidateOptionsInvalid() { @@ -37,9 +37,6 @@ public function testValidateOptionsInvalid() $baseOptions = new BaseOptions($input); $result = $baseOptions->validateOptions($options); - //Assert - $this->expectException($result); - Mockery::close(); } From 1271b38c5984b2db9766813e1283ec70937be973 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 15:39:20 +0630 Subject: [PATCH 05/13] refactor of compatible for phpunit9 --- tests/testBaseOptions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/testBaseOptions.php b/tests/testBaseOptions.php index ed852f8..44576f8 100644 --- a/tests/testBaseOptions.php +++ b/tests/testBaseOptions.php @@ -3,6 +3,7 @@ use Mockery; use Mookofe\Tail\BaseOptions; use PHPUnit\Framework\TestCase; +use Mookofe\Tail\Exceptions\InvalidOptionException; /** @@ -27,12 +28,15 @@ public function testValidateOptions() } /** - * @expectedException Mookofe\Tail\Exceptions\InvalidOptionException + * ExpectedException Mookofe\Tail\Exceptions\InvalidOptionException */ public function testValidateOptionsInvalid() { $input = Mockery::mock('Illuminate\Config\Repository'); + //Assert + $this->expectException(InvalidOptionException::class); + $options = array('invalid_field' => 'this_is_invalid_field'); $baseOptions = new BaseOptions($input); $result = $baseOptions->validateOptions($options); From d3b79f97523f9f259665987b6103bbe510aab4cd Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 15:56:09 +0630 Subject: [PATCH 06/13] travis only for php7.2 --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 79f5f5b..ff60671 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: php php: - - 5.4 - - 5.5 - - 5.6 - 7.2 - hhvm @@ -12,4 +9,4 @@ before_script: - composer install --prefer-source --no-interaction --dev # script: build.sh -script: phpunit --configuration phpunit.xml --coverage-text \ No newline at end of file +script: phpunit --configuration phpunit.xml --coverage-text From f40df8be75cbb1fb0509ce7482e9b12538bb5470 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 15:57:46 +0630 Subject: [PATCH 07/13] travis only for php7.2 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff60671..7e2521c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: php php: - 7.2 - - hhvm before_script: - composer self-update From 779a3649f43bfde7d77dadf3912cec510530c6b0 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 16:30:26 +0630 Subject: [PATCH 08/13] modify travis for backwork compatible --- .travis.yml | 22 +++++++---- tests/testBaseOptionsOld.php | 76 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 tests/testBaseOptionsOld.php diff --git a/.travis.yml b/.travis.yml index 79f5f5b..e08cbfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,21 @@ language: php -php: - - 5.4 - - 5.5 - - 5.6 - - 7.2 - - hhvm +php: 5.6 + env: LARAVEL='5.4.*' +php: 7.2 + env: LARAVEL='6.0' +php: hhvm-3.18 + sudo: required + dist: trusty + env: LARAVEL='5.4.*' XDEBUG=1 + +before_install: + - travis_retry composer self-update before_script: - - composer self-update - composer install --prefer-source --no-interaction --dev # script: build.sh -script: phpunit --configuration phpunit.xml --coverage-text \ No newline at end of file +script: + - if [[ $LARAVEL == '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptions + - if [[ $LARAVEL != '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptionsOld \ No newline at end of file diff --git a/tests/testBaseOptionsOld.php b/tests/testBaseOptionsOld.php new file mode 100644 index 0000000..4d98614 --- /dev/null +++ b/tests/testBaseOptionsOld.php @@ -0,0 +1,76 @@ + + */ +class testBaseOptionsOld extends \PHPUnit_Framework_TestCase +{ + + protected $input; + + public function __construct() + { + $this->input = Mockery::mock('Illuminate\Config\Repository'); + + } + + public function tearDown() + { + Mockery::close(); + } + + public function testValidateOptions() + { + $options = array('queue_name' => 'this_queue'); + $baseOptions = new BaseOptions($this->input); + + $result = $baseOptions->validateOptions($options); + + //Asserts + $this->assertInstanceOf('Mookofe\Tail\BaseOptions', $result); + } + + /** + * @expectedException Mookofe\Tail\Exceptions\InvalidOptionException + */ + public function testValidateOptionsInvalid() + { + $options = array('invalid_field' => 'this_is_invalid_field'); + $baseOptions = new BaseOptions($this->input); + + $result = $baseOptions->validateOptions($options); + } + + public function testSetOptions() + { + $options = array('queue_name' => 'this_queue'); + $baseOptions = new BaseOptions($this->input); + + $baseOptions->setOptions($options); + + //Assertss + $this->assertObjectHasAttribute('queue_name', $baseOptions); + $this->assertEquals($baseOptions->queue_name, $options['queue_name']); + } + + public function testBuildConnectionOptions() + { + //Mock Input object + $this->input->shouldReceive('get')->once()->andReturn('just_to_return'); + $this->input->shouldReceive('get')->once()->andReturn(array()); + + //Setup enviroment + $baseOptions = new BaseOptions($this->input); + $options = $baseOptions->buildConnectionOptions(); + + //Asserts + $this->assertInternalType('array', $options); + $this->assertArrayHasKey('queue_name', $options); + } +} \ No newline at end of file From b3cd5604065d5128b8174166d42d2cf2a0b36eaa Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 16:34:41 +0630 Subject: [PATCH 09/13] modify travis for backwork compatible --- .travis.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index e08cbfd..f1c8c11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,19 @@ language: php -php: 5.6 - env: LARAVEL='5.4.*' -php: 7.2 - env: LARAVEL='6.0' -php: hhvm-3.18 - sudo: required - dist: trusty - env: LARAVEL='5.4.*' XDEBUG=1 +matrix: + include: + - php: 5.6 + env: LARAVEL='5.4.*' + - php: 7.2 + env: LARAVEL='6.0' + - php: hhvm + env: LARAVEL='5.4.*' before_install: - travis_retry composer self-update -before_script: - - composer install --prefer-source --no-interaction --dev +install: + - travis_retry composer install --prefer-source --no-interaction --dev # script: build.sh script: From f95074ede9b670947cb5a5fd2dbe103aa5bb59b2 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 16:36:45 +0630 Subject: [PATCH 10/13] modify travis for backwork compatible --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f1c8c11..53d5375 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,5 @@ install: # script: build.sh script: - - if [[ $LARAVEL == '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptions - - if [[ $LARAVEL != '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptionsOld \ No newline at end of file + - if [[ $LARAVEL == '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptions; fi + - if [[ $LARAVEL != '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptionsOld; fi \ No newline at end of file From 4152d7ea338501bf984c2d80b80ec8ef1ae91fa7 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 16:43:57 +0630 Subject: [PATCH 11/13] modify travis for backwork compatible --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53d5375..f3efeba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,9 @@ matrix: env: LARAVEL='5.4.*' - php: 7.2 env: LARAVEL='6.0' - - php: hhvm + - php: hhvm-3.18 + sudo: required + dist: trusty env: LARAVEL='5.4.*' before_install: @@ -17,5 +19,5 @@ install: # script: build.sh script: - - if [[ $LARAVEL == '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptions; fi - - if [[ $LARAVEL != '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text --filter=testBaseOptionsOld; fi \ No newline at end of file + - if [[ $LARAVEL == '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text tests/testBaseOptions.php; fi + - if [[ $LARAVEL != '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text tests/testBaseOptionsOld.php; fi \ No newline at end of file From 1cccc894a365c85cc1cd1d7193f4a3527a37a7cc Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 16:47:55 +0630 Subject: [PATCH 12/13] modify travis for backwork compatible --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f3efeba..ceda8bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ matrix: - php: hhvm-3.18 sudo: required dist: trusty - env: LARAVEL='5.4.*' + env: LARAVEL='6.0.*' before_install: - travis_retry composer self-update From dfe02e782693585115950f39fe13ddb03ffd0de4 Mon Sep 17 00:00:00 2001 From: Paing Hein Thu Date: Mon, 9 Sep 2019 16:56:52 +0630 Subject: [PATCH 13/13] Remove hhvm in test env --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ceda8bc..da861ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,6 @@ matrix: env: LARAVEL='5.4.*' - php: 7.2 env: LARAVEL='6.0' - - php: hhvm-3.18 - sudo: required - dist: trusty - env: LARAVEL='6.0.*' before_install: - travis_retry composer self-update @@ -20,4 +16,4 @@ install: # script: build.sh script: - if [[ $LARAVEL == '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text tests/testBaseOptions.php; fi - - if [[ $LARAVEL != '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text tests/testBaseOptionsOld.php; fi \ No newline at end of file + - if [[ $LARAVEL != '6.0' ]]; then phpunit --configuration phpunit.xml --coverage-text tests/testBaseOptionsOld.php; fi