PageRenderTime 29ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/Croogo/Test/Case/Model/Behavior/ParamsBehaviorTest.php

https://github.com/kareypowell/croogo
PHP | 125 lines | 105 code | 10 blank | 10 comment | 0 complexity | df4913be94b9c4c129e83293d88c1c54 MD5 | raw file
  1. <?php
  2. App::uses('Type', 'Taxonomy.Model');
  3. App::uses('CroogoTestCase', 'Croogo.TestSuite');
  4. class ParamsBehaviorTest extends CroogoTestCase {
  5. public $fixtures = array(
  6. 'plugin.users.aco',
  7. 'plugin.users.aro',
  8. 'plugin.users.aros_aco',
  9. 'plugin.blocks.block',
  10. 'plugin.comments.comment',
  11. 'plugin.contacts.contact',
  12. 'plugin.translate.i18n',
  13. 'plugin.settings.language',
  14. 'plugin.menus.link',
  15. 'plugin.menus.menu',
  16. 'plugin.contacts.message',
  17. 'plugin.meta.meta',
  18. 'plugin.nodes.node',
  19. 'plugin.taxonomy.model_taxonomy',
  20. 'plugin.blocks.region',
  21. 'plugin.users.role',
  22. 'plugin.settings.setting',
  23. 'plugin.taxonomy.taxonomy',
  24. 'plugin.taxonomy.term',
  25. 'plugin.taxonomy.type',
  26. 'plugin.taxonomy.types_vocabulary',
  27. 'plugin.users.user',
  28. 'plugin.taxonomy.vocabulary',
  29. );
  30. public $Type = null;
  31. /**
  32. * setUp
  33. *
  34. * @return void
  35. */
  36. public function setUp() {
  37. parent::setUp();
  38. $this->Type = ClassRegistry::init('Taxonomy.Type');
  39. }
  40. /**
  41. * tearDown
  42. *
  43. * @return void
  44. */
  45. public function tearDown() {
  46. parent::tearDown();
  47. unset($this->Type);
  48. ClassRegistry::flush();
  49. }
  50. public function testSingle() {
  51. $this->Type->save(array(
  52. 'title' => 'Article',
  53. 'alias' => 'article',
  54. 'description' => 'Article Types',
  55. 'params' => 'param1=value1',
  56. ));
  57. $type = $this->Type->findByAlias('article');
  58. $expected = array(
  59. 'param1' => 'value1',
  60. );
  61. $this->assertEqual($type['Params'], $expected);
  62. }
  63. public function testMultiple() {
  64. $this->Type->save(array(
  65. 'title' => 'Article',
  66. 'alias' => 'article',
  67. 'description' => 'Article Types',
  68. 'params' => "param1=value1\nparam2=value2",
  69. ));
  70. $type = $this->Type->findByAlias('article');
  71. $expected = array(
  72. 'param1' => 'value1',
  73. 'param2' => 'value2',
  74. );
  75. $this->assertEqual($type['Params'], $expected);
  76. }
  77. public function testMixedLineEndings() {
  78. $this->Type->save(array(
  79. 'title' => 'Article',
  80. 'alias' => 'article',
  81. 'description' => 'Article Types',
  82. 'params' => "param1=value1\r\nparam2=value2\rparam3=value3\nparam4=value4",
  83. ));
  84. $type = $this->Type->findByAlias('article');
  85. $expected = array(
  86. 'param1' => 'value1',
  87. 'param2' => 'value2',
  88. 'param3' => 'value3',
  89. 'param4' => 'value4',
  90. );
  91. $this->assertEqual($type['Params'], $expected);
  92. }
  93. public function testEmbeddedOptions() {
  94. $this->Type->save(array(
  95. 'title' => 'Article',
  96. 'alias' => 'article',
  97. 'description' => 'Article Types',
  98. 'params' => "param1=value1\r\n[options:linkAttr escape=true escapeTitle=false foo=a:b;c:d;e:f]",
  99. ));
  100. $type = $this->Type->findByAlias('article');
  101. $expected = array(
  102. 'param1' => 'value1',
  103. 'linkAttr' => array(
  104. 'escape' => 'true',
  105. 'escapeTitle' => 'false',
  106. 'foo' => array(
  107. 'a' => 'b',
  108. 'c' => 'd',
  109. 'e' => 'f',
  110. ),
  111. ),
  112. );
  113. $this->assertEqual($type['Params'], $expected);
  114. }
  115. }