Skip to content

Commit

Permalink
Fixing intial travis problems, adding more tests for application file
Browse files Browse the repository at this point in the history
  • Loading branch information
Danzabar committed Nov 24, 2014
1 parent e513c19 commit abbef61
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ install:
- travis_retry composer install --no-interaction --prefer-source --dev

script:
- sudo chmod -R 0777 app/cache
- mkdir -p build/logs
- phpunit --coverage-clover build/logs/clover.xml

Expand Down
4 changes: 2 additions & 2 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public function formatArgs($args)
// Anything that remains are params
return Array(
'task' => $command[0],
'action' => (!isset($command[1]) ? $command[1] : 'main'),
'params' => $args
'action' => (isset($command[1]) ? $command[1] : 'main'),
'params' => array_values($args)
);
}

Expand Down
47 changes: 44 additions & 3 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
$this->console = m::mock('Console');
$this->di = m::mock('Phalcon\DI\FactoryDefault\CLI');
$this->di = m::mock('CLI');

$this->application = new Application($this->console);
}
Expand All @@ -57,10 +57,51 @@ public function setUp()
public function test_vars()
{
$this->console->shouldReceive('setDI')->once();

$this->application->setDI($this->di);

$this->assertInstanceOf('Phalcon\DI\FactoryDefault\CLI', $this->application->getDI());
$this->assertInstanceOf('CLI', $this->application->getDI());
$this->assertInstanceOf('Console', $this->application->getConsole());
}

/**
* Test the args come out in right way when we provide all the info it needs
*
* @return void
* @author Dan Cox
*/
public function test_sortArgsWithAll()
{
$test = $this->application->formatArgs(Array(
'cli',
'command:action',
'param1',
'param2'
));

$this->assertEquals(
Array('task' => 'command', 'action' => 'action', 'params' => Array('param1', 'param2')),
$test
);
}

/**
* Test similiar to above but without providing an action
*
* @return void
* @author Dan Cox
*/
public function test_sortArgsWithoutAction()
{
$test = $this->application->formatArgs(Array(
'cli',
'command',
'param1'
));

$this->assertEquals(
Array('task' => 'command', 'action' => 'main', 'params' => Array('param1')),
$test
);
}


Expand Down

0 comments on commit abbef61

Please sign in to comment.