DispatcherTest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\tests\cases\test;
  9. use lithium\test\Group;
  10. use lithium\test\Report;
  11. use lithium\test\Dispatcher;
  12. use lithium\util\Collection;
  13. use lithium\tests\mocks\test\cases\MockTest;
  14. use lithium\tests\mocks\test\cases\MockTestErrorHandling;
  15. use lithium\tests\mocks\test\cases\MockSkipThrowsException;
  16. use lithium\tests\mocks\test\cases\MockSetUpThrowsException;
  17. use lithium\tests\mocks\test\cases\MockTearDownThrowsException;
  18. class DispatcherTest extends \lithium\test\Unit {
  19. public function testRunDefaults() {
  20. $report = Dispatcher::run();
  21. $this->assertTrue($report instanceof Report);
  22. $result = $report->group;
  23. $this->assertTrue($result instanceof Group);
  24. }
  25. public function testRunWithReporter() {
  26. $report = Dispatcher::run(null, array(
  27. 'reporter' => function($info) {
  28. return $info;
  29. }
  30. ));
  31. $this->assertTrue($report instanceof Report);
  32. $result = $report->group;
  33. $this->assertTrue($result instanceof Group);
  34. }
  35. public function testRunCaseWithString() {
  36. $report = Dispatcher::run('lithium\tests\mocks\test\MockUnitTest');
  37. $expected = 'lithium\tests\mocks\test\MockUnitTest';
  38. $result = $report->title;
  39. $this->assertEqual($expected, $result);
  40. $expected = 'testNothing';
  41. $result = $report->results['group'][0][0]['method'];
  42. $this->assertEqual($expected, $result);
  43. $expected = 'pass';
  44. $result = $report->results['group'][0][0]['result'];
  45. $this->assertEqual($expected, $result);
  46. }
  47. public function testRunGroupWithString() {
  48. $report = Dispatcher::run('lithium\tests\mocks\test');
  49. $expected = 'lithium\tests\mocks\test';
  50. $result = $report->title;
  51. $this->assertEqual($expected, $result);
  52. $expected = new Collection(array('data' => array(
  53. new MockSetUpThrowsException(),
  54. new MockSkipThrowsException(),
  55. new MockTearDownThrowsException(),
  56. new MockTest(),
  57. new MockTestErrorHandling()
  58. )));
  59. $result = $report->group->tests();
  60. $this->assertEqual($expected, $result);
  61. $expected = 'testNothing';
  62. $result = $report->results['group'][3][0]['method'];
  63. $this->assertEqual($expected, $result);
  64. $expected = 'pass';
  65. $result = $report->results['group'][3][0]['result'];
  66. $this->assertEqual($expected, $result);
  67. }
  68. }
  69. ?>