Fixed typo, added CmsCompoundObject::getComponentProperties method test. Credit to @viamage
This commit is contained in:
viamage 2017-12-27 20:31:34 +01:00 committed by Luke Towers
parent 06780f5123
commit 7ffb79a5fd
2 changed files with 21 additions and 2 deletions

View File

@ -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]);
}

View File

@ -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');