diff --git a/.travis.yml b/.travis.yml index 3ac492e..d779663 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,19 @@ language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - composer self-update - - composer install --prefer-source --no-interaction --dev - + +matrix: + include: + - php: 5.6 + env: LARAVEL='5.4.*' + - php: 7.2 + env: LARAVEL='6.0' + +before_install: + - travis_retry composer self-update + +install: + - travis_retry 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 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 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..44576f8 100644 --- a/tests/testBaseOptions.php +++ b/tests/testBaseOptions.php @@ -2,75 +2,78 @@ use Mockery; use Mookofe\Tail\BaseOptions; +use PHPUnit\Framework\TestCase; +use Mookofe\Tail\Exceptions\InvalidOptionException; /** * 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(); } /** - * @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($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->assertIsArray($options); $this->assertArrayHasKey('queue_name', $options); + + Mockery::close(); } } \ 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