2010-07-14 01:58:21 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* TestSuiteShell test case
|
|
|
|
*
|
|
|
|
* PHP 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.libs
|
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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
App::import('Shell', 'Shell', false);
|
2010-10-18 03:43:12 +00:00
|
|
|
App::import('Shell', 'Testsuite');
|
2010-07-14 01:58:21 +00:00
|
|
|
|
2010-10-03 05:53:42 +00:00
|
|
|
require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
|
2010-10-17 19:43:20 +00:00
|
|
|
|
2010-07-14 01:58:21 +00:00
|
|
|
|
|
|
|
class TestSuiteShellTest extends CakeTestCase {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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(
|
|
|
|
'TestSuiteShell',
|
2010-10-06 03:51:08 +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');
|
|
|
|
$this->Shell->expects($this->at(0))->method('out')->with(__("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')
|
|
|
|
->with(new PHPUnit_Framework_Constraint_PCREMatch('/\[1\].*/'));
|
|
|
|
$this->Shell->expects($this->at(2))->method('out')
|
|
|
|
->with(new PHPUnit_Framework_Constraint_PCREMatch('/\[2\].*/'));
|
|
|
|
|
|
|
|
$this->Shell->expects($this->once())->method('in')
|
|
|
|
->with(__('What test case would you like to run?'), null, 'q')
|
|
|
|
->will($this->returnValue('1'));
|
|
|
|
|
|
|
|
$this->Shell->expects($this->once())->method('run');
|
|
|
|
$this->Shell->available();
|
|
|
|
$this->assertEquals($this->Shell->args, array('core', 'Basics'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
|
|
$this->Shell->expects($this->once())->method('run')
|
|
|
|
->with(
|
2011-02-13 18:08:43 +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();
|
|
|
|
}
|
|
|
|
}
|