2010-07-14 01:58:21 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* TestSuiteShell test case
|
|
|
|
*
|
|
|
|
* PHP 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2011-05-29 21:31:39 +00:00
|
|
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-07-14 01:58:21 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2011-05-29 21:31:39 +00:00
|
|
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-07-14 01:58:21 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command
|
2010-07-14 01:58:21 +00:00
|
|
|
* @since CakePHP(tm) v 2.0
|
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
|
|
|
*/
|
|
|
|
|
2010-12-09 05:13:11 +00:00
|
|
|
App::uses('ShellDispatcher', 'Console');
|
2011-03-08 18:48:46 +00:00
|
|
|
App::uses('TestsuiteShell', 'Console/Command');
|
2010-07-14 01:58:21 +00:00
|
|
|
|
2011-03-08 18:48:46 +00:00
|
|
|
class TestsuiteShellTest extends CakeTestCase {
|
2010-07-14 01:58:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setUp test case
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setUp() {
|
2010-10-24 19:11:30 +00:00
|
|
|
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
|
|
2010-07-14 01:58:21 +00:00
|
|
|
$this->Shell = $this->getMock(
|
2011-03-08 18:48:46 +00:00
|
|
|
'TestsuiteShell',
|
2011-08-21 05:04:55 +00:00
|
|
|
array('in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', '_run', 'clear'),
|
2010-10-24 19:11:30 +00:00
|
|
|
array($out, $out, $in)
|
2010-07-14 01:58:21 +00:00
|
|
|
);
|
2010-11-21 19:39:07 +00:00
|
|
|
$this->Shell->OptionParser = $this->getMock('ConsoleOptionParser', array(), array(null, false));
|
2010-07-14 01:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tearDown method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function tearDown() {
|
|
|
|
unset($this->Dispatch, $this->Shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test available list of test cases for an empty category
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testAvailableWithEmptyList() {
|
|
|
|
$this->Shell->startup();
|
|
|
|
$this->Shell->args = array('unexistant-category');
|
2011-03-19 17:48:00 +00:00
|
|
|
$this->Shell->expects($this->at(0))->method('out')->with(__d('cake_console', "No test cases available \n\n"));
|
2010-11-21 19:39:07 +00:00
|
|
|
$this->Shell->OptionParser->expects($this->once())->method('help');
|
2010-07-14 01:58:21 +00:00
|
|
|
$this->Shell->available();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test available list of test cases for core category
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testAvailableCoreCategory() {
|
|
|
|
$this->Shell->startup();
|
|
|
|
$this->Shell->args = array('core');
|
|
|
|
$this->Shell->expects($this->at(0))->method('out')->with('Core Test Cases:');
|
|
|
|
$this->Shell->expects($this->at(1))->method('out')
|
2011-09-29 04:35:15 +00:00
|
|
|
->with($this->stringContains('[1]'));
|
2010-07-14 01:58:21 +00:00
|
|
|
$this->Shell->expects($this->at(2))->method('out')
|
2011-09-29 04:35:15 +00:00
|
|
|
->with($this->stringContains('[2]'));
|
2011-03-19 17:48:00 +00:00
|
|
|
|
2010-07-14 01:58:21 +00:00
|
|
|
$this->Shell->expects($this->once())->method('in')
|
2011-03-19 17:48:00 +00:00
|
|
|
->with(__d('cake_console', 'What test case would you like to run?'), null, 'q')
|
2010-07-14 01:58:21 +00:00
|
|
|
->will($this->returnValue('1'));
|
|
|
|
|
2011-08-21 05:04:55 +00:00
|
|
|
$this->Shell->expects($this->once())->method('_run');
|
2010-07-14 01:58:21 +00:00
|
|
|
$this->Shell->available();
|
2011-04-12 02:46:19 +00:00
|
|
|
$this->assertEquals($this->Shell->args, array('core', 'AllBehaviors'));
|
2010-07-14 01:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that correct option for test runner are passed
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testRunnerOptions() {
|
|
|
|
$this->Shell->startup();
|
|
|
|
$this->Shell->args = array('core', 'Basics');
|
2010-10-16 04:42:37 +00:00
|
|
|
$this->Shell->params = array('filter' => 'myFilter', 'colors' => true, 'verbose' => true);
|
2010-07-14 01:58:21 +00:00
|
|
|
|
2011-08-21 05:04:55 +00:00
|
|
|
$this->Shell->expects($this->once())->method('_run')
|
2010-07-14 01:58:21 +00:00
|
|
|
->with(
|
2011-04-12 02:46:19 +00:00
|
|
|
array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'),
|
2010-10-11 05:33:24 +00:00
|
|
|
array('--filter', 'myFilter', '--colors', '--verbose')
|
2010-07-14 01:58:21 +00:00
|
|
|
);
|
|
|
|
$this->Shell->main();
|
|
|
|
}
|
2011-03-19 17:48:00 +00:00
|
|
|
}
|