PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Cake/Test/Case/Console/Command/TestsuiteShellTest.php

https://bitbucket.org/udeshika/fake_twitter
PHP | 105 lines | 51 code | 12 blank | 42 comment | 0 complexity | a4b50f8f25010c472ee5aebc9ee9e556 MD5 | raw file
  1. <?php
  2. /**
  3. * TestSuiteShell test case
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package Cake.Test.Case.Console.Command
  16. * @since CakePHP(tm) v 2.0
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. App::uses('ShellDispatcher', 'Console');
  20. App::uses('TestsuiteShell', 'Console/Command');
  21. class TestsuiteShellTest extends CakeTestCase {
  22. /**
  23. * setUp test case
  24. *
  25. * @return void
  26. */
  27. public function setUp() {
  28. $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
  29. $in = $this->getMock('ConsoleInput', array(), array(), '', false);
  30. $this->Shell = $this->getMock(
  31. 'TestsuiteShell',
  32. array('in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', '_run', 'clear'),
  33. array($out, $out, $in)
  34. );
  35. $this->Shell->OptionParser = $this->getMock('ConsoleOptionParser', array(), array(null, false));
  36. }
  37. /**
  38. * tearDown method
  39. *
  40. * @return void
  41. */
  42. public function tearDown() {
  43. unset($this->Dispatch, $this->Shell);
  44. }
  45. /**
  46. * test available list of test cases for an empty category
  47. *
  48. * @return void
  49. */
  50. public function testAvailableWithEmptyList() {
  51. $this->Shell->startup();
  52. $this->Shell->args = array('unexistant-category');
  53. $this->Shell->expects($this->at(0))->method('out')->with(__d('cake_console', "No test cases available \n\n"));
  54. $this->Shell->OptionParser->expects($this->once())->method('help');
  55. $this->Shell->available();
  56. }
  57. /**
  58. * test available list of test cases for core category
  59. *
  60. * @return void
  61. */
  62. public function testAvailableCoreCategory() {
  63. $this->Shell->startup();
  64. $this->Shell->args = array('core');
  65. $this->Shell->expects($this->at(0))->method('out')->with('Core Test Cases:');
  66. $this->Shell->expects($this->at(1))->method('out')
  67. ->with($this->stringContains('[1]'));
  68. $this->Shell->expects($this->at(2))->method('out')
  69. ->with($this->stringContains('[2]'));
  70. $this->Shell->expects($this->once())->method('in')
  71. ->with(__d('cake_console', 'What test case would you like to run?'), null, 'q')
  72. ->will($this->returnValue('1'));
  73. $this->Shell->expects($this->once())->method('_run');
  74. $this->Shell->available();
  75. $this->assertEquals($this->Shell->args, array('core', 'AllBehaviors'));
  76. }
  77. /**
  78. * Tests that correct option for test runner are passed
  79. *
  80. * @return void
  81. */
  82. public function testRunnerOptions() {
  83. $this->Shell->startup();
  84. $this->Shell->args = array('core', 'Basics');
  85. $this->Shell->params = array('filter' => 'myFilter', 'colors' => true, 'verbose' => true);
  86. $this->Shell->expects($this->once())->method('_run')
  87. ->with(
  88. array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'),
  89. array('--filter', 'myFilter', '--colors', '--verbose')
  90. );
  91. $this->Shell->main();
  92. }
  93. }