You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

  1. <?php
  2. /*
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage UnitTests
  7. * @since 2011-11-1
  8. *
  9. * Action_TestCase class for testing Actions
  10. */
  11. require_once dirname(__FILE__) . '/../../Load.php';
  12. require_once dirname(__FILE__) . '/../../classes/Env.class.php';
  13. require_once dirname(__FILE__) . '/../../exception/ErrorHandler.php';
  14. require_once dirname(__FILE__) . '/../../app/FrontController.php';
  15. require_once dirname(__FILE__) . '/../../app/Action.php';
  16. class Action_TestCase extends PHPUnit_Framework_TestCase
  17. {
  18. public function run(PHPUnit_Framework_TestResult $result = NULL)
  19. {
  20. $this->setPreserveGlobalState(false);
  21. return parent::run($result);
  22. }
  23. public function setUp()
  24. {
  25. $this->getMock('Router');
  26. $this->getMock('PHPView', array('fetch', 'assignObject'));
  27. }
  28. public function tearDown()
  29. {
  30. $env = new ReflectionClass('Env');
  31. $params = $env->getProperty('params');
  32. $params->setAccessible(true);
  33. $params->setValue('Env', array());
  34. }
  35. }
  36. class SomeView
  37. {
  38. private $result = array();
  39. public function fetch($template)
  40. {
  41. $this->result['template'] = $template;
  42. return $this->result;
  43. }
  44. public function assignObject() {}
  45. public function assign($name, $value) {
  46. $this->result[$name] = $value;
  47. }
  48. }