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.

58 lines
1.5 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__) . '/../../Registry.php';
  12. require_once dirname(__FILE__) . '/../../Config.php';
  13. require_once dirname(__FILE__) . '/../../Load.php';
  14. require_once dirname(__FILE__) . '/../../classes/Env.class.php';
  15. require_once dirname(__FILE__) . '/../../exception/ErrorHandler.php';
  16. require_once dirname(__FILE__) . '/../../app/FrontController.php';
  17. require_once dirname(__FILE__) . '/../../app/Action.php';
  18. class Action_TestCase extends PHPUnit_Framework_TestCase
  19. {
  20. public function run(PHPUnit_Framework_TestResult $result = NULL)
  21. {
  22. $this->setPreserveGlobalState(false);
  23. return parent::run($result);
  24. }
  25. public function setUp()
  26. {
  27. $this->getMock('Router');
  28. $this->getMock('PHPView', array('fetch', 'assignObject'));
  29. }
  30. public function tearDown()
  31. {
  32. $env = new ReflectionClass('Env');
  33. $params = $env->getProperty('params');
  34. $params->setAccessible(true);
  35. $params->setValue('Env', array());
  36. }
  37. }
  38. class SomeView
  39. {
  40. private $result = array();
  41. public function fetch($template)
  42. {
  43. $this->result['template'] = $template;
  44. return $this->result;
  45. }
  46. public function assignObject() {}
  47. public function assign($name, $value) {
  48. $this->result[$name] = $value;
  49. }
  50. }