Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
language: php

php:
- 7.2
matrix:
include:
- php: 5.6
env: LARAVEL='5.4.*'
- php: 7.2
env: LARAVEL='6.0'

before_install:
- travis_retry composer self-update

before_script:
- composer self-update
- composer install --prefer-source --no-interaction --dev
install:
- travis_retry composer install --prefer-source --no-interaction --dev

# script: build.sh
script: phpunit --configuration phpunit.xml --coverage-text
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
76 changes: 76 additions & 0 deletions tests/testBaseOptionsOld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php namespace Mookofe\Tail\Test;

use Mockery;
use Mookofe\Tail\BaseOptions;


/**
* Test base option class
*
* @author Victor Cruz <cruzrosario@gmail.com>
*/
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);
}
}