PageRenderTime 36ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/tests/Service/TemplateTest.php

https://bitbucket.org/SallyCMS/0.4
PHP | 70 lines | 35 code | 14 blank | 21 comment | 0 complexity | 78cc60a40104359e025fb428f35f8e9f MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /*
  3. * Copyright (c) 2011, webvariants GbR, http://www.webvariants.de
  4. *
  5. * This file is released under the terms of the MIT license. You can find the
  6. * complete text in the attached LICENSE file or online at:
  7. *
  8. * http://www.opensource.org/licenses/mit-license.php
  9. */
  10. class sly_Service_TemplateTest extends PHPUnit_Framework_TestCase {
  11. private static $filename;
  12. private static $uniqid;
  13. public static function setUpBeforeClass() {
  14. $uniqid = 'abc'.uniqid();
  15. $filename = 'template.'.$uniqid.'.php';
  16. $testfile = <<<TESTFILE
  17. <?php
  18. print "Hallo Welt!";
  19. /**
  20. * Dieses Template ist ein Beispiel.
  21. *
  22. * @sly name $uniqid
  23. * @sly title Mein super tolles Template!!!1elf
  24. * @sly slots [links, rechts]
  25. * @sly modules [gallery, foobar, james]
  26. * @sly class [article, meta]
  27. * @sly custom 42
  28. */
  29. Hallo REX_ARTICLE[id=1]!
  30. \$x = 4;
  31. print \$x + 5;
  32. TESTFILE;
  33. $service = sly_Service_Factory::getTemplateService();
  34. $folder = $service->getFolder();
  35. // create test template file
  36. self::$filename = sly_Util_Directory::join($folder, $filename);
  37. self::$uniqid = $uniqid;
  38. file_put_contents(self::$filename, $testfile);
  39. try {
  40. // PHPUnit converts all notices to Exceptions, but in this case we don't really care.
  41. $service->refresh();
  42. }
  43. catch (PHPUnit_Framework_Error $e) {
  44. // pass...
  45. }
  46. }
  47. public static function tearDownAfterClass() {
  48. unlink(self::$filename);
  49. }
  50. public function testGetParams() {
  51. $service = sly_Service_Factory::getTemplateService();
  52. $this->assertEquals(self::$uniqid, $service->get(self::$uniqid, 'name'));
  53. $this->assertEquals('Mein super tolles Template!!!1elf', $service->getTitle(self::$uniqid));
  54. $this->assertEquals(42, $service->get(self::$uniqid, 'custom'));
  55. }
  56. }