From 7ffb79a5fd54fcd71dccf28861a87a71e7153803 Mon Sep 17 00:00:00 2001 From: viamage Date: Wed, 27 Dec 2017 20:31:34 +0100 Subject: [PATCH] Fix typo (#3326) Fixed typo, added CmsCompoundObject::getComponentProperties method test. Credit to @viamage --- modules/cms/classes/CmsCompoundObject.php | 2 +- .../cms/classes/CmsCompoundObjectTest.php | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/cms/classes/CmsCompoundObject.php b/modules/cms/classes/CmsCompoundObject.php index 32a7e7ba9..8eea1b5d0 100644 --- a/modules/cms/classes/CmsCompoundObject.php +++ b/modules/cms/classes/CmsCompoundObject.php @@ -301,7 +301,7 @@ class CmsCompoundObject extends CmsObject else { foreach ($this->settings['components'] as $name => $settings) { $nameParts = explode(' ', $name); - if (count($nameParts > 1)) { + if (count($nameParts) > 1) { $name = trim($nameParts[0]); } diff --git a/tests/unit/cms/classes/CmsCompoundObjectTest.php b/tests/unit/cms/classes/CmsCompoundObjectTest.php index 98d3dd6b3..5d47553b3 100644 --- a/tests/unit/cms/classes/CmsCompoundObjectTest.php +++ b/tests/unit/cms/classes/CmsCompoundObjectTest.php @@ -29,9 +29,10 @@ class CmsCompoundObjectTest extends TestCase public function setUp() { parent::setUp(); - Model::clearBootedModels(); Model::flushEventListeners(); + include_once base_path() . '/tests/fixtures/plugins/october/tester/components/Archive.php'; + include_once base_path() . '/tests/fixtures/plugins/october/tester/components/Post.php'; } public function testLoadFile() @@ -94,6 +95,24 @@ class CmsCompoundObjectTest extends TestCase $this->assertFalse($obj->hasComponent('October\Tester\Components\BigSummer')); } + public function testGetComponentProperties() + { + $theme = Theme::load('test'); + + $obj = TestCmsCompoundObject::load($theme, 'components.htm'); + + $properties = $obj->getComponentProperties('October\Tester\Components\Post'); + $emptyProperties = $obj->getComponentProperties('October\Tester\Components\Archive'); + $notExistingProperties = $obj->getComponentProperties('This\Is\Not\Component'); + $this->assertInternalType('array', $properties); + $this->assertArrayHasKey('show-featured', $properties); + $this->assertTrue((bool)$properties['show-featured']); + $this->assertEquals('true', $properties['show-featured']); + $this->assertCount(1, $properties); + $this->assertCount(0, $emptyProperties); + $this->assertCount(0, $notExistingProperties); + } + public function testCache() { $theme = Theme::load('test');