7 protected $dynamicContent =
'/Content.Node/index.html';
9 protected $dynamicSource;
15 protected $mockRepositoryApi;
17 protected $oldRepositoryApi;
19 public function setUp()
23 Yii::app()->cache->flush();
26 $this->dynamicSource->cacheFolder = Yii::app()->getModule(
'contentSource')->sourceSettings[
'DynamicContentSource'][
'cacheFolder'];
27 $this->dynamicSource->usePersonalisation =
true;
28 $this->dynamicSource->personalisationFields = Yii::app()->getModule(
'contentSource')->sourceSettings[
'DynamicContentSource'][
'personalisationFields'];
29 $this->dynamicSource->init();
30 @unlink($this->dynamicSource->contentFile($this->dynamicContent));
33 $this->fsSource->contentFolder = Yii::app()->getModule(
'contentSource')->sourceSettings[
'FileSystemContentSource'][
'contentFolder'];
34 $this->fsSource->usePersonalisation =
true;
35 $this->fsSource->personalisationFields = Yii::app()->getModule(
'contentSource')->sourceSettings[
'FileSystemContentSource'][
'personalisationFields'];
36 $this->fsSource->init();
38 $this->oldRepositoryApi = Yii::app()->repositoryApi;
39 $this->mockRepositoryApi = $this->getMock(
'RepositoryApi', array(
'getContentAttributes'));
40 $this->mockRepositoryApi->expects($this->any())
41 ->method(
'getContentAttributes')
42 ->will($this->returnValue(require (Yii::getPathOfAlias(
'site.tests.runtime.contentSource') .
'/testAttributes_getContentAttributes.php')));
43 Yii::app()->setComponent(
'repositoryApi', $this->mockRepositoryApi);
46 public function tearDown()
48 Yii::app()->setComponent(
'repositoryApi', $this->oldRepositoryApi);
49 @unlink($this->dynamicSource->contentFile($this->dynamicContent));
52 public function testDynamicSourceAttributes()
54 $this->mockRepositoryApi->expects($this->any())
55 ->method(
'getCmsObject')
56 ->will($this->returnValue(require (Yii::getPathOfAlias(
'site.tests.runtime.contentSource') .
'/testGetDynamicContent_getCmsObject.php'))
59 $content =
new Content($this->dynamicSource, $this->dynamicContent);
60 $this->assertTrue(is_array($content->getAttributes()));
61 $this->assertTrue(in_array(
'marketing',$content->getPersonalisationAttributes()));
64 public function testFileSystemSourceAttributes()
66 $content =
new Content($this->fsSource, $this->dynamicContent);
67 $this->assertTrue(is_array($content->getAttributes()));
68 $this->assertTrue(in_array(
'marketing',$content->getPersonalisationAttributes()));