14 protected $dynamicContent =
'/Content.Node/index.html';
15 protected $staticContent =
'/Content.Node/files/css/audioplayerv1.min.css';
21 protected $oldRepositoryApi;
25 protected $mockRepositoryApi;
27 public function setUp()
31 Yii::app()->cache->flush();
34 $this->source->cacheFolder = Yii::app()->getModule(
'contentSource')->sourceSettings[
'DynamicContentSource'][
'cacheFolder'];
35 $this->source->init();
37 $this->oldRepositoryApi = Yii::app()->repositoryApi;
38 $this->mockRepositoryApi = $this->getMock(
'RepositoryApi', array(
'getCmsObject',
'getLastModificationTime'));
39 $this->mockRepositoryApi->contentExternalHost =
'test.com';
40 Yii::app()->setComponent(
'repositoryApi', $this->mockRepositoryApi);
43 public function tearDown()
45 Yii::app()->setComponent(
'repositoryApi', $this->oldRepositoryApi);
47 @unlink($this->source->contentFile($this->dynamicContent));
48 @unlink($this->source->contentFile($this->staticContent));
51 public function testGetDynamicContent()
53 $this->mockRepositoryApi->expects($this->any())
54 ->method(
'getCmsObject')
55 ->will($this->returnValue(require (Yii::getPathOfAlias(
'site.tests.runtime.contentSource') .
'/testGetDynamicContent_getCmsObject.php'))
58 $content = $this->source->getContent($this->dynamicContent);
59 $this->assertFileExists($content->getFile());
62 public function testGetStaticContent()
64 $this->mockRepositoryApi->expects($this->any())
65 ->method(
'getCmsObject')
66 ->will($this->returnValue(require (Yii::getPathOfAlias(
'site.tests.runtime.contentSource') .
'/testGetStaticContent_getCmsObject.php'))
68 $content = $this->source->getContent($this->staticContent);
69 $this->assertFileExists($content->getFile());
72 public function testGetSavedContent()
74 $this->mockRepositoryApi->expects($this->once())
75 ->method(
'getCmsObject')
76 ->will($this->returnValue(require (Yii::getPathOfAlias(
'site.tests.runtime.contentSource') .
'/testGetDynamicContent_getCmsObject.php'))
78 $this->mockRepositoryApi->expects($this->once())
79 ->method(
'getLastModificationTime')
80 ->will($this->returnValue(
'1339749121'));
82 $content = $this->source->getContent($this->dynamicContent);
83 $this->assertFileExists($content->getFile());
85 $content = $this->source->getContent($this->dynamicContent);
86 $this->assertFileExists($content->getFile());
89 public function testGetFailedContent()
91 $this->mockRepositoryApi->expects($this->exactly(1))
92 ->method(
'getCmsObject')
93 ->will($this->returnValue(
false));
95 $content = $this->source->getContent($this->dynamicContent);
96 $this->assertFalse($content);