Update tests with minor API changes for Halcyon implementation
This commit is contained in:
parent
864d38b77e
commit
8e3ff0c700
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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' => '<p>Hello, world!</p>',
|
||||
'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' => '<p>Hello, world!</p>',
|
||||
|
|
@ -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'],
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Cms\Classes\Page;
|
||||
use Cms\Classes\Theme;
|
||||
use Cms\Classes\Layout;
|
||||
|
||||
class CmsObjectQueryTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Register theme with Halcyon
|
||||
Theme::load('test');
|
||||
|
||||
TestCmsCompoundObject::flushEventListeners();
|
||||
}
|
||||
|
||||
public function testWhere()
|
||||
{
|
||||
$page = Page::where('layout', 'caramba')->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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue