BlueprintTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. use Grav\Common\Data\Blueprint;
  3. /**
  4. * Class InstallCommandTest
  5. */
  6. class BlueprintTest extends \Codeception\TestCase\Test
  7. {
  8. /**
  9. */
  10. public function testValidateStrict()
  11. {
  12. $blueprint = $this->loadBlueprint('strict');
  13. $blueprint->validate(['test' => 'string']);
  14. }
  15. /**
  16. * @depends testValidateStrict
  17. * @expectedException Grav\Common\Data\ValidationException
  18. */
  19. public function testValidateStrictRequired()
  20. {
  21. $blueprint = $this->loadBlueprint('strict');
  22. $blueprint->validate([]);
  23. }
  24. /**
  25. * @depends testValidateStrict
  26. * @expectedException Grav\Common\Data\ValidationException
  27. */
  28. public function testValidateStrictExtra()
  29. {
  30. $blueprint = $this->loadBlueprint('strict');
  31. $blueprint->validate(['test' => 'string', 'wrong' => 'field']);
  32. die();
  33. }
  34. /**
  35. * @param string $filename
  36. * @return Blueprint
  37. */
  38. protected function loadBlueprint($filename)
  39. {
  40. $blueprint = new Blueprint('strict');
  41. $blueprint->setContext(dirname(__DIR__, 3). '/data/blueprints');
  42. $blueprint->load()->init();
  43. return $blueprint;
  44. }
  45. }