/Croogo/Test/Case/Model/Behavior/ParamsBehaviorTest.php
PHP | 125 lines | 105 code | 10 blank | 10 comment | 0 complexity | df4913be94b9c4c129e83293d88c1c54 MD5 | raw file
- <?php
- App::uses('Type', 'Taxonomy.Model');
- App::uses('CroogoTestCase', 'Croogo.TestSuite');
- class ParamsBehaviorTest extends CroogoTestCase {
- public $fixtures = array(
- 'plugin.users.aco',
- 'plugin.users.aro',
- 'plugin.users.aros_aco',
- 'plugin.blocks.block',
- 'plugin.comments.comment',
- 'plugin.contacts.contact',
- 'plugin.translate.i18n',
- 'plugin.settings.language',
- 'plugin.menus.link',
- 'plugin.menus.menu',
- 'plugin.contacts.message',
- 'plugin.meta.meta',
- 'plugin.nodes.node',
- 'plugin.taxonomy.model_taxonomy',
- 'plugin.blocks.region',
- 'plugin.users.role',
- 'plugin.settings.setting',
- 'plugin.taxonomy.taxonomy',
- 'plugin.taxonomy.term',
- 'plugin.taxonomy.type',
- 'plugin.taxonomy.types_vocabulary',
- 'plugin.users.user',
- 'plugin.taxonomy.vocabulary',
- );
- public $Type = null;
- /**
- * setUp
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- $this->Type = ClassRegistry::init('Taxonomy.Type');
- }
- /**
- * tearDown
- *
- * @return void
- */
- public function tearDown() {
- parent::tearDown();
- unset($this->Type);
- ClassRegistry::flush();
- }
- public function testSingle() {
- $this->Type->save(array(
- 'title' => 'Article',
- 'alias' => 'article',
- 'description' => 'Article Types',
- 'params' => 'param1=value1',
- ));
- $type = $this->Type->findByAlias('article');
- $expected = array(
- 'param1' => 'value1',
- );
- $this->assertEqual($type['Params'], $expected);
- }
- public function testMultiple() {
- $this->Type->save(array(
- 'title' => 'Article',
- 'alias' => 'article',
- 'description' => 'Article Types',
- 'params' => "param1=value1\nparam2=value2",
- ));
- $type = $this->Type->findByAlias('article');
- $expected = array(
- 'param1' => 'value1',
- 'param2' => 'value2',
- );
- $this->assertEqual($type['Params'], $expected);
- }
- public function testMixedLineEndings() {
- $this->Type->save(array(
- 'title' => 'Article',
- 'alias' => 'article',
- 'description' => 'Article Types',
- 'params' => "param1=value1\r\nparam2=value2\rparam3=value3\nparam4=value4",
- ));
- $type = $this->Type->findByAlias('article');
- $expected = array(
- 'param1' => 'value1',
- 'param2' => 'value2',
- 'param3' => 'value3',
- 'param4' => 'value4',
- );
- $this->assertEqual($type['Params'], $expected);
- }
- public function testEmbeddedOptions() {
- $this->Type->save(array(
- 'title' => 'Article',
- 'alias' => 'article',
- 'description' => 'Article Types',
- 'params' => "param1=value1\r\n[options:linkAttr escape=true escapeTitle=false foo=a:b;c:d;e:f]",
- ));
- $type = $this->Type->findByAlias('article');
- $expected = array(
- 'param1' => 'value1',
- 'linkAttr' => array(
- 'escape' => 'true',
- 'escapeTitle' => 'false',
- 'foo' => array(
- 'a' => 'b',
- 'c' => 'd',
- 'e' => 'f',
- ),
- ),
- );
- $this->assertEqual($type['Params'], $expected);
- }
- }