ViewTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
  2. /**
  3. * Tests the View class
  4. *
  5. * @group kohana
  6. * @group kohana.core
  7. * @group kohana.core.view
  8. *
  9. * @package Kohana
  10. * @category Tests
  11. * @author Kohana Team
  12. * @copyright (c) 2008-2012 Kohana Team
  13. * @license http://kohanaframework.org/license
  14. */
  15. class Kohana_ViewTest extends Unittest_TestCase
  16. {
  17. protected static $old_modules = array();
  18. /**
  19. * Setups the filesystem for test view files
  20. *
  21. * @return null
  22. */
  23. // @codingStandardsIgnoreStart
  24. public static function setupBeforeClass()
  25. // @codingStandardsIgnoreEnd
  26. {
  27. self::$old_modules = Kohana::modules();
  28. $new_modules = self::$old_modules+array(
  29. 'test_views' => realpath(dirname(__FILE__).'/../test_data/')
  30. );
  31. Kohana::modules($new_modules);
  32. }
  33. /**
  34. * Restores the module list
  35. *
  36. * @return null
  37. */
  38. // @codingStandardsIgnoreStart
  39. public static function teardownAfterClass()
  40. // @codingStandardsIgnoreEnd
  41. {
  42. Kohana::modules(self::$old_modules);
  43. }
  44. /**
  45. * Provider for test_instaniate
  46. *
  47. * @return array
  48. */
  49. public function provider_instantiate()
  50. {
  51. return array(
  52. array('kohana/error', FALSE),
  53. array('test.css', FALSE),
  54. array('doesnt_exist', TRUE),
  55. );
  56. }
  57. /**
  58. * Tests that we can instantiate a view file
  59. *
  60. * @test
  61. * @dataProvider provider_instantiate
  62. *
  63. * @return null
  64. */
  65. public function test_instantiate($path, $expects_exception)
  66. {
  67. try
  68. {
  69. $view = new View($path);
  70. $this->assertSame(FALSE, $expects_exception);
  71. }
  72. catch(View_Exception $e)
  73. {
  74. $this->assertSame(TRUE, $expects_exception);
  75. }
  76. }
  77. }