PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/tr/tests/cases/lmbDetachedFixtureTest.class.php

https://bitbucket.org/idler/mmp/
PHP | 62 lines | 43 code | 12 blank | 7 comment | 0 complexity | 9cb1fc204605119138352edca0c40ff5 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0
  1. <?php
  2. /*
  3. * Limb PHP Framework
  4. *
  5. * @link http://limb-project.com
  6. * @copyright Copyright &copy; 2004-2009 BIT(http://bit-creative.com)
  7. * @license LGPL http://www.gnu.org/copyleft/lesser.html
  8. */
  9. require_once(dirname(__FILE__) . '/../common.inc.php');
  10. require_once(dirname(__FILE__) . '/../../src/lmbDetachedFixture.class.php');
  11. class lmbDetachedFixtureTest extends lmbTestRunnerBase
  12. {
  13. function setUp()
  14. {
  15. $this->_rmdir(LIMB_VAR_DIR);
  16. mkdir(LIMB_VAR_DIR);
  17. }
  18. function tearDown()
  19. {
  20. $this->_rmdir(LIMB_VAR_DIR);
  21. }
  22. function testSetupTearDown()
  23. {
  24. file_put_contents(LIMB_VAR_DIR . '/.setup.php', '<?php echo "wow"; ?>');
  25. file_put_contents(LIMB_VAR_DIR . '/.teardown.php', '<?php echo "hey"; ?>');
  26. $fixture = new lmbDetachedFixture(LIMB_VAR_DIR . '/.setup.php',
  27. LIMB_VAR_DIR . '/.teardown.php');
  28. ob_start();
  29. $fixture->setUp();
  30. $fixture->tearDown();
  31. $str = ob_get_contents();
  32. ob_end_clean();
  33. $this->assertEqual($str, 'wowhey');
  34. }
  35. function testFixtureCanAccessThisWithoutPHPErrors()
  36. {
  37. file_put_contents(LIMB_VAR_DIR . '/.setup.php', '<?php $this->test = "test"; ?>');
  38. file_put_contents(LIMB_VAR_DIR . '/.teardown.php', '<?php echo $this->test; ?>');
  39. $fixture = new lmbDetachedFixture(LIMB_VAR_DIR . '/.setup.php',
  40. LIMB_VAR_DIR . '/.teardown.php');
  41. ob_start();
  42. $old = error_reporting(E_ALL);
  43. $fixture->setUp();
  44. $fixture->tearDown();
  45. error_reporting($old);
  46. $str = ob_get_contents();
  47. ob_end_clean();
  48. $this->assertEqual($str, 'test');
  49. }
  50. }