PageRenderTime 51ms CodeModel.GetById 7ms RepoModel.GetById 1ms app.codeStats 0ms

/recess/test/recess/framework/helpers/LayoutTest.php

http://github.com/recess/recess
PHP | 64 lines | 54 code | 10 blank | 0 comment | 0 complexity | 61161c6c6bf3868fcf28a048a50993f2 MD5 | raw file
Possible License(s): MIT, GPL-2.0
  1. <?php
  2. Library::import('recess.framework.helpers.Layout');
  3. class LayoutTest extends PHPUnit_Framework_TestCase {
  4. protected $zero = 'zero-input';
  5. protected $single = 'single-input';
  6. protected $multi = 'multi-input';
  7. protected $optional = 'optional-inputs';
  8. function setUp() {
  9. Layout::addPath(dirname(__FILE__) . '/test-layouts/');
  10. }
  11. function testSimple() {
  12. ob_start();
  13. Layout::draw('simple.php', array());
  14. $content = ob_get_clean();
  15. $this->assertEquals('simple', $content);
  16. }
  17. function testContext() {
  18. ob_start();
  19. Layout::draw('context.php', array('context'=>'is valuable'));
  20. $content = ob_get_clean();
  21. $this->assertEquals('is valuable', $content);
  22. }
  23. function testContextFail() {
  24. ob_start();
  25. try {
  26. Layout::draw('context.php', array('contextFail'=>'is valuable'));
  27. $this->fail('Should throw MissingRequiredInputException');
  28. } catch(MissingRequiredInputException $e) {
  29. $this->assertTrue(true);
  30. } catch(Exception $e) {
  31. $this->fail('Should throw MissingRequiredInputException. Threw: ' . get_class($e));
  32. }
  33. }
  34. function testMultiple() {
  35. ob_start();
  36. Layout::draw('multiple.php', array());
  37. $content = ob_get_clean();
  38. $this->assertEquals('great success', $content);
  39. }
  40. function testDefaults() {
  41. ob_start();
  42. Layout::draw('defaults.php', array());
  43. $content = ob_get_clean();
  44. $this->assertEquals('great success', $content);
  45. }
  46. function testMiddle() {
  47. ob_start();
  48. Layout::draw('middle.php', array());
  49. $content = ob_get_clean();
  50. $string = 'child middle master';
  51. $this->assertEquals($string.$string, $content);
  52. }
  53. }
  54. ?>