-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Templateable Models + Template Properties
Related to locomotivemtl/charcoal-property#39ecc3e Changes: - `TemplateProperty`: Revised use of available templates based - `TemplateOptionsProperty`: Revised `TemplateProperty` usage - `TemplateableTrait`: Ignore numbers as template options values - Completed unit tests for the affected properties and mixins - Updated `phpunit.xml` to test `Admin` and `Property` namespaces
- Loading branch information
Showing
8 changed files
with
524 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Charcoal\Tests\Property; | ||
|
||
use InvalidArgumentException; | ||
|
||
// From 'charcoal-property' | ||
use Charcoal\Cms\TemplateableTrait; | ||
|
||
/** | ||
* Template Property Test | ||
*/ | ||
class TemplateableTraitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
use \Charcoal\Tests\Cms\ContainerIntegrationTrait; | ||
|
||
/** | ||
* Tested Class. | ||
* | ||
* @var TemplateableTrait | ||
*/ | ||
public $obj; | ||
|
||
/** | ||
* Set up the test. | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->obj = $this->getMockForTrait(TemplateableTrait::class); | ||
} | ||
|
||
public function testTemplateIdent() | ||
{ | ||
$this->assertNull($this->obj->templateIdent()); | ||
|
||
$this->obj->setTemplateIdent('foobar'); | ||
$this->assertEquals('foobar', $this->obj->templateIdent()); | ||
} | ||
|
||
public function testControllerIdent() | ||
{ | ||
$this->assertNull($this->obj->controllerIdent()); | ||
|
||
$this->obj->setControllerIdent('foobar'); | ||
$this->assertEquals('foobar', $this->obj->controllerIdent()); | ||
} | ||
|
||
public function testTemplateOptions() | ||
{ | ||
$this->assertInternalType('array', $this->obj->templateOptions()); | ||
$this->assertEmpty($this->obj->templateOptions()); | ||
|
||
$this->obj->setTemplateOptions(false); | ||
$this->assertFalse($this->obj->templateOptions()); | ||
|
||
$this->obj->setTemplateOptions(42); | ||
$this->assertNull($this->obj->templateOptions()); | ||
|
||
$this->obj->setTemplateOptions('foobar'); | ||
$this->assertNull($this->obj->templateOptions()); | ||
|
||
$this->obj->setTemplateOptions('{"foo":"bar"}'); | ||
$this->assertEquals([ 'foo' => 'bar' ], $this->obj->templateOptions()); | ||
|
||
$this->obj->setTemplateOptions([ 'foo' => 'bar' ]); | ||
$this->assertEquals([ 'foo' => 'bar' ], $this->obj->templateOptions()); | ||
|
||
$obj = new \stdClass(); | ||
$this->obj->setTemplateOptions($obj); | ||
$this->assertEquals($obj, $this->obj->templateOptions()); | ||
} | ||
} |
Oops, something went wrong.