diff --git a/tests/PluginTestCase.php b/tests/PluginTestCase.php index 2229d4ad3..581780869 100644 --- a/tests/PluginTestCase.php +++ b/tests/PluginTestCase.php @@ -187,7 +187,7 @@ abstract class PluginTestCase extends Illuminate\Foundation\Testing\TestCase { $reflect = new ReflectionClass($this); $path = $reflect->getFilename(); - $basePath = plugins_path(); + $basePath = $this->app->pluginsPath(); $result = false; diff --git a/tests/unit/cms/classes/CmsCompoundObjectTest.php b/tests/unit/cms/classes/CmsCompoundObjectTest.php index 893beec5f..7f32d9fa0 100644 --- a/tests/unit/cms/classes/CmsCompoundObjectTest.php +++ b/tests/unit/cms/classes/CmsCompoundObjectTest.php @@ -6,26 +6,26 @@ use Cms\Classes\CmsCompoundObject; class TestCmsCompoundObject extends CmsCompoundObject { - protected function parseSettings() {} + protected $dirName = 'testobjects'; - public static function getObjectTypeDirName() - { - return 'testobjects'; - } + protected function parseSettings() {} } class TestTemporaryCmsCompoundObject extends CmsCompoundObject { - protected function parseSettings() {} + protected $dirName = 'temporary'; - public static function getObjectTypeDirName() - { - return 'temporary'; - } + protected function parseSettings() {} } -class CmsCompoundObjectTest extends TestCase +class CmsCompoundObjectTest extends TestCase { + public function tearDown() + { + parent::tearDown(); + TestCmsCompoundObject::flushEventListeners(); + } + public function testLoadFile() { $theme = Theme::load('test'); @@ -159,9 +159,7 @@ class CmsCompoundObjectTest extends TestCase public function testUndefinedProperty() { - $theme = Theme::load('test'); - - $obj = new TestCmsCompoundObject($theme); + $obj = new TestCmsCompoundObject; $this->assertNull($obj->something); } @@ -175,7 +173,7 @@ class CmsCompoundObjectTest extends TestCase $this->assertFileNotExists($destFilePath); - $obj = new TestCmsCompoundObject($theme); + $obj = TestCmsCompoundObject::inTheme($theme); $obj->fill([ 'markup' => '

Hello, world!

', 'fileName'=>'compound-markup' @@ -199,7 +197,7 @@ class CmsCompoundObjectTest extends TestCase $this->assertFileNotExists($destFilePath); - $obj = new TestCmsCompoundObject($theme); + $obj = TestCmsCompoundObject::inTheme($theme); $obj->fill([ 'settings'=>['var'=>'value'], 'markup' => '

Hello, world!

', @@ -225,7 +223,7 @@ class CmsCompoundObjectTest extends TestCase $this->assertFileNotExists($destFilePath); - $obj = new TestCmsCompoundObject($theme); + $obj = TestCmsCompoundObject::inTheme($theme); $obj->fill([ 'fileName'=>'compound', 'settings'=>['var'=>'value'], diff --git a/tests/unit/cms/classes/CmsExceptionTest.php b/tests/unit/cms/classes/CmsExceptionTest.php index a67e53f12..dec08530f 100644 --- a/tests/unit/cms/classes/CmsExceptionTest.php +++ b/tests/unit/cms/classes/CmsExceptionTest.php @@ -67,7 +67,7 @@ class CmsExceptionTest extends TestCase $exception = new CmsException($page, 300); $exception->setMask($foreignException); - $this->assertEquals($page->getFullPath(), $exception->getFile()); + $this->assertEquals($page->getFilePath(), $exception->getFile()); $this->assertEquals('PHP Content', $exception->getErrorType()); $this->assertEquals('This is a general error', $exception->getMessage()); } diff --git a/tests/unit/cms/classes/CmsObjectQueryTest.php b/tests/unit/cms/classes/CmsObjectQueryTest.php index a7fcef313..7ae39aa17 100644 --- a/tests/unit/cms/classes/CmsObjectQueryTest.php +++ b/tests/unit/cms/classes/CmsObjectQueryTest.php @@ -1,10 +1,21 @@ first(); @@ -90,7 +101,10 @@ class CmsObjectQueryTest extends TestCase "placeholder", "sidebar", ], $layouts); + } + public function testListsNonExistentTheme() + { $pages = Page::inTheme('NON_EXISTENT_THEME')->lists('baseFileName'); $this->assertEmpty($pages); } diff --git a/tests/unit/cms/classes/CmsObjectTest.php b/tests/unit/cms/classes/CmsObjectTest.php index 24166c19a..cc72f3c39 100644 --- a/tests/unit/cms/classes/CmsObjectTest.php +++ b/tests/unit/cms/classes/CmsObjectTest.php @@ -5,18 +5,12 @@ use Cms\Classes\Theme; class TestCmsObject extends CmsObject { - public static function getObjectTypeDirName() - { - return 'testobjects'; - } + protected $dirName = 'testobjects'; } class TestTemporaryCmsObject extends CmsObject { - public static function getObjectTypeDirName() - { - return 'temporary'; - } + protected $dirName = 'temporary'; } class CmsObjectTest extends TestCase @@ -30,7 +24,7 @@ class CmsObjectTest extends TestCase $this->assertEquals('plain.html', $obj->getFileName()); $path = $theme->getPath().'/testobjects/plain.html'; - $this->assertEquals($path, $obj->getFullPath()); + $this->assertEquals($path, $obj->getFilePath()); $this->assertEquals(filemtime($path), $obj->mtime); } @@ -43,7 +37,7 @@ class CmsObjectTest extends TestCase $this->assertEquals('subdir/obj.html', $obj->getFileName()); $path = $theme->getPath().'/testobjects/subdir/obj.html'; - $this->assertEquals($path, $obj->getFullPath()); + $this->assertEquals($path, $obj->getFilePath()); $this->assertEquals(filemtime($path), $obj->mtime); } @@ -129,30 +123,28 @@ class CmsObjectTest extends TestCase $theme = Theme::load('apitest'); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'fileName'=>'mytestobj', - 'content'=>$testContents + 'fileName' => 'mytestobj', + 'content' => $testContents ]); $this->assertEquals($testContents, $obj->getContent()); $this->assertEquals('mytestobj.htm', $obj->getFileName()); } - /** - * @expectedException \October\Rain\Exception\ApplicationException - * @expectedExceptionMessage The property 'something' cannot be set - */ public function testFillNotFillable() { $theme = Theme::load('apitest'); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'something'=>'mytestobj', - 'content'=>$testContents + 'something' => 'mytestobj', + 'content' => $testContents ]); + + $this->assertNull($obj->something); } /** @@ -164,10 +156,11 @@ class CmsObjectTest extends TestCase $theme = Theme::load('apitest'); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'fileName'=>'@name' + 'fileName' => '@name' ]); + $obj->save(); } /** @@ -179,13 +172,13 @@ class CmsObjectTest extends TestCase $theme = Theme::load('apitest'); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'fileName'=>'../somefile' + 'fileName' => '../somefile' ]); + $obj->save(); } - /** * @expectedException \October\Rain\Exception\ValidationException * @expectedExceptionMessage Invalid file name @@ -195,10 +188,11 @@ class CmsObjectTest extends TestCase $theme = Theme::load('apitest'); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'fileName'=>'/somefile' + 'fileName' => '/somefile' ]); + $obj->save(); } /** @@ -210,10 +204,11 @@ class CmsObjectTest extends TestCase $theme = Theme::load('apitest'); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'fileName'=>' ' + 'fileName' => ' ' ]); + $obj->save(); } public function testSave() @@ -227,10 +222,10 @@ class CmsObjectTest extends TestCase $this->assertFileNotExists($destFilePath); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'fileName'=>'mytestobj', - 'content'=>$testContents + 'fileName' => 'mytestobj', + 'content' => $testContents ]); $obj->save(); @@ -257,7 +252,7 @@ class CmsObjectTest extends TestCase $this->assertEquals($testContents, $obj->getContent()); $obj->fill([ - 'fileName'=>'anotherobj' + 'fileName' => 'anotherobj' ]); $obj->save(); @@ -284,7 +279,7 @@ class CmsObjectTest extends TestCase $this->assertFileExists($destFilePath); $obj = TestCmsObject::load($theme, 'anotherobj.htm'); - $obj->fill(['fileName'=>'existingobj']); + $obj->fill(['fileName' => 'existingobj']); $obj->save(); } @@ -302,8 +297,8 @@ class CmsObjectTest extends TestCase $obj = TestCmsObject::load($theme, 'anotherobj.htm'); $obj->fill([ - 'fileName'=>'anotherobj', - 'content'=>$testContents + 'fileName' => 'anotherobj', + 'content' => $testContents ]); $obj->save(); @@ -327,10 +322,10 @@ class CmsObjectTest extends TestCase $this->assertFileNotExists($destDirPath); $testContents = 'mytestcontent'; - $obj = new TestCmsObject($theme); + $obj = TestCmsObject::inTheme($theme); $obj->fill([ - 'fileName'=>'testsubdir/mytestobj.htm', - 'content'=>$testContents + 'fileName' => 'testsubdir/mytestobj.htm', + 'content' => $testContents ]); $obj->save(); diff --git a/tests/unit/cms/classes/CodeParserTest.php b/tests/unit/cms/classes/CodeParserTest.php index 2f3275216..431aa129d 100644 --- a/tests/unit/cms/classes/CodeParserTest.php +++ b/tests/unit/cms/classes/CodeParserTest.php @@ -95,7 +95,7 @@ class CodeParserTest extends TestCase * Test caching - update the file modification time and reset the internal cache. The file should be parsed. */ - $this->assertTrue(@touch($layout->getFullPath())); + $this->assertTrue(@touch($layout->getFilePath())); $layout = Layout::load($theme, 'php-parser-test.htm'); $this->assertNotEmpty($layout); $parser = new CodeParser($layout); diff --git a/tests/unit/cms/classes/ControllerTest.php b/tests/unit/cms/classes/ControllerTest.php index 0c60429e8..66e468369 100644 --- a/tests/unit/cms/classes/ControllerTest.php +++ b/tests/unit/cms/classes/ControllerTest.php @@ -2,9 +2,15 @@ use Cms\Classes\Theme; use Cms\Classes\Controller; +use Cms\Classes\CmsCompoundObject; class ControllerTest extends TestCase { + public function tearDown() + { + parent::tearDown(); + CmsCompoundObject::flushEventListeners(); + } public function testThemeUrl() { diff --git a/tests/unit/cms/classes/RouterTest.php b/tests/unit/cms/classes/RouterTest.php index 12c3c402f..9e867dc75 100644 --- a/tests/unit/cms/classes/RouterTest.php +++ b/tests/unit/cms/classes/RouterTest.php @@ -7,8 +7,10 @@ class RouterTest extends TestCase { protected static $theme = null; - public static function setUpBeforeClass() + public function setUp() { + parent::setUp(); + self::$theme = Theme::load('test'); } diff --git a/tests/unit/cms/classes/ThemeTest.php b/tests/unit/cms/classes/ThemeTest.php index bf9e061cd..c9e2368e6 100644 --- a/tests/unit/cms/classes/ThemeTest.php +++ b/tests/unit/cms/classes/ThemeTest.php @@ -41,7 +41,8 @@ class ThemeTest extends TestCase { $theme = Theme::load('test'); - $pages = $theme->listPages(); + $pageCollection = $theme->listPages(); + $pages = array_values($pageCollection->all()); $this->assertInternalType('array', $pages); $expectedPageNum = $this->countThemePages(base_path().'/tests/fixtures/themes/test/pages');