Fix typo (#3326)
Fixed typo, added CmsCompoundObject::getComponentProperties method test. Credit to @viamage
This commit is contained in:
parent
06780f5123
commit
7ffb79a5fd
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue