Fixes unit tests

This commit is contained in:
Samuel Georges 2014-12-10 17:42:50 +11:00
parent 9f8eb58591
commit 65845686c4
8 changed files with 55 additions and 110 deletions

View File

@ -28,8 +28,7 @@ class CmsCompoundObjectTest extends TestCase
{
public function testLoadFile()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$obj = TestCmsCompoundObject::load($theme, 'compound.htm');
$this->assertContains("\$controller->data['something'] = 'some value'", $obj->code);
@ -53,8 +52,7 @@ class CmsCompoundObjectTest extends TestCase
public function testParseComponentSettings()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$obj = TestCmsCompoundObject::load($theme, 'component.htm');
$this->assertArrayHasKey('components', $obj->settings);
@ -66,8 +64,7 @@ class CmsCompoundObjectTest extends TestCase
public function testCache()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$themePath = $theme->getPath();
/*
@ -138,8 +135,7 @@ class CmsCompoundObjectTest extends TestCase
public function testUndefinedProperty()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$obj = new TestCmsCompoundObject($theme);
$this->assertNull($obj->something);
@ -147,8 +143,7 @@ class CmsCompoundObjectTest extends TestCase
public function testSaveMarkup()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$destFilePath = $theme->getPath().'/testobjects/compound-markup.htm';
if (file_exists($destFilePath))
@ -172,8 +167,7 @@ class CmsCompoundObjectTest extends TestCase
public function testSaveMarkupAndSettings()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$destFilePath = $theme->getPath().'/testobjects/compound-markup-settings.htm';
if (file_exists($destFilePath))
@ -198,8 +192,7 @@ class CmsCompoundObjectTest extends TestCase
public function testSaveFull()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$destFilePath = $theme->getPath().'/testobjects/compound.htm';
if (file_exists($destFilePath))

View File

@ -82,8 +82,7 @@ class CmsExceptionTest extends TestCase
public function testCmsExceptionPhp()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$router = new Router($theme);
$page = $router->findByUrl('/throw-php');

View File

@ -23,8 +23,7 @@ class CmsObjectTest extends TestCase
{
public function testLoad()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$obj = TestCmsObject::load($theme, 'plain.html');
$this->assertEquals('<p>This is a test HTML content file.</p>', $obj->getContent());
@ -37,8 +36,7 @@ class CmsObjectTest extends TestCase
public function testLoadFromSubdirectory()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$obj = TestCmsObject::load($theme, 'subdir/obj.html');
$this->assertEquals('<p>This is an object in a subdirectory.</p>', $obj->getContent());
@ -51,24 +49,21 @@ class CmsObjectTest extends TestCase
public function testValidateLoadInvalidTheme()
{
$theme = new Theme();
$theme->load('none');
$theme = Theme::load('none');
$this->assertNull(TestCmsObject::load($theme, 'plain.html'));
}
public function testValidateLoadInvalidFile()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$this->assertNull(TestCmsObject::load($theme, 'none'));
}
public function testCache()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$themePath = $theme->getPath();
$filePath = $themePath .= '/temporary/test.htm';
@ -131,8 +126,7 @@ class CmsObjectTest extends TestCase
public function testFillFillable()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$testContents = 'mytestcontent';
$obj = new TestCmsObject($theme);
@ -151,8 +145,7 @@ class CmsObjectTest extends TestCase
*/
public function testFillNotFillable()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$testContents = 'mytestcontent';
$obj = new TestCmsObject($theme);
@ -168,8 +161,7 @@ class CmsObjectTest extends TestCase
*/
public function testFillInvalidFileNameSymbol()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$testContents = 'mytestcontent';
$obj = new TestCmsObject($theme);
@ -184,8 +176,7 @@ class CmsObjectTest extends TestCase
*/
public function testFillInvalidFileNamePath()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$testContents = 'mytestcontent';
$obj = new TestCmsObject($theme);
@ -201,8 +192,7 @@ class CmsObjectTest extends TestCase
*/
public function testFillInvalidFileSlash()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$testContents = 'mytestcontent';
$obj = new TestCmsObject($theme);
@ -217,8 +207,7 @@ class CmsObjectTest extends TestCase
*/
public function testFillEmptyFileName()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$testContents = 'mytestcontent';
$obj = new TestCmsObject($theme);
@ -229,8 +218,7 @@ class CmsObjectTest extends TestCase
public function testSave()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$destFilePath = $theme->getPath().'/testobjects/mytestobj.htm';
if (file_exists($destFilePath))
@ -255,8 +243,7 @@ class CmsObjectTest extends TestCase
*/
public function testRename()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$srcFilePath = $theme->getPath().'/testobjects/mytestobj.htm';
$this->assertFileExists($srcFilePath);
@ -286,8 +273,7 @@ class CmsObjectTest extends TestCase
*/
public function testRenameToExistingFile()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$srcFilePath = $theme->getPath().'/testobjects/anotherobj.htm';
$this->assertFileExists($srcFilePath);
@ -307,8 +293,7 @@ class CmsObjectTest extends TestCase
*/
public function testSaveSameName()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$filePath = $theme->getPath().'/testobjects/anotherobj.htm';
$this->assertFileExists($filePath);
@ -328,8 +313,7 @@ class CmsObjectTest extends TestCase
public function testSaveNewDir()
{
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$destFilePath = $theme->getPath().'/testobjects/testsubdir/mytestobj.htm';
if (file_exists($destFilePath))

View File

@ -19,8 +19,7 @@ class CodeParserTest extends TestCase
public function testParser()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$layout = Layout::load($theme, 'php-parser-test.htm');
$this->assertNotEmpty($layout);
@ -110,8 +109,7 @@ class CodeParserTest extends TestCase
public function testParseNoPhp()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$layout = Layout::load($theme, 'no-php.htm');
$this->assertNotEmpty($layout);
@ -137,8 +135,7 @@ class CodeParserTest extends TestCase
public function testParsePage()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$page = Page::load($theme, 'cycle-test.htm');
$this->assertNotEmpty($page);
@ -168,8 +165,7 @@ class CodeParserTest extends TestCase
public function testOptionalPhpTags()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
/*
* Test short PHP tags
@ -237,8 +233,7 @@ class CodeParserTest extends TestCase
public function testNamespaces()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$page = Page::load($theme, 'code-namespaces.htm');
$this->assertNotEmpty($page);

View File

@ -104,8 +104,7 @@ class ComponentManagerTest extends TestCase
private function spoofPageCode()
{
// Spoof all the objects we need to make a page object
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$page = Page::load($theme, 'index.htm');
$layout = Layout::load($theme, 'content.htm');
$controller = new Controller($theme);

View File

@ -10,8 +10,7 @@ class ControllerTest extends TestCase
/*
* Test the built-in 404 page
*/
$theme = new Theme();
$theme->load('apitest');
$theme = Theme::load('apitest');
$controller = new Controller($theme);
$response = $controller->run('/some-page-that-doesnt-exist');
$this->assertNotEmpty($response);
@ -25,8 +24,7 @@ class ControllerTest extends TestCase
/*
* Test the theme 404 page
*/
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/some-page-that-doesnt-exist');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -40,8 +38,7 @@ class ControllerTest extends TestCase
/*
* Test the / route and the fallback layout
*/
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -56,8 +53,7 @@ class ControllerTest extends TestCase
*/
public function testLayoutNotFound()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/no-layout');
}
@ -67,8 +63,7 @@ class ControllerTest extends TestCase
/*
* Test existing layout
*/
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/with-layout');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -81,8 +76,7 @@ class ControllerTest extends TestCase
/*
* Test partials referred in the layout and page
*/
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/with-partials')->getContent();
$this->assertEquals('<div>LAYOUT PARTIAL<p>Hey PAGE PARTIAL Homer Simpson A partial</p></div>', $response);
@ -90,8 +84,7 @@ class ControllerTest extends TestCase
public function testContent()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/with-content')->getContent();
$this->assertEquals('<div>LAYOUT CONTENT<p>Hey PAGE CONTENT A content</p></div>', $response);
@ -99,8 +92,7 @@ class ControllerTest extends TestCase
public function testBlocks()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/with-placeholder')->getContent();
$this->assertEquals("<div>LAYOUT CONTENT <span>BLOCK\n DEFAULT</span> <p>Hey PAGE CONTENT</p></div>SECOND BLOCK", $response);
@ -108,8 +100,7 @@ class ControllerTest extends TestCase
public function testLayoutInSubdirectory()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/apage')->getContent();
$this->assertEquals("<div>LAYOUT CONTENT <h1>This page is a subdirectory</h1></div>", $response);
@ -121,16 +112,14 @@ class ControllerTest extends TestCase
*/
public function testPartialNotFound()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/no-partial')->getContent();
}
public function testPageLifeCycle()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/cycle-test')->getContent();
$this->assertEquals('12345', $response);
@ -158,8 +147,7 @@ class ControllerTest extends TestCase
{
App::instance('request', $this->configAjaxRequestMock('onNoHandler', ''));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/ajax-test');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -173,8 +161,7 @@ class ControllerTest extends TestCase
{
App::instance('request', $this->configAjaxRequestMock('delete'));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/ajax-test');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -188,8 +175,7 @@ class ControllerTest extends TestCase
{
App::instance('request', $this->configAjaxRequestMock('onTest', 'p:artial'));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/ajax-test');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -203,8 +189,7 @@ class ControllerTest extends TestCase
{
App::instance('request', $this->configAjaxRequestMock('onTest', 'partial'));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/ajax-test');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -218,8 +203,7 @@ class ControllerTest extends TestCase
{
App::instance('request', $this->configAjaxRequestMock('onTest', 'ajax-result'));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/ajax-test');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -236,8 +220,7 @@ class ControllerTest extends TestCase
{
App::instance('request', $this->configAjaxRequestMock('onTestLayout', 'ajax-result'));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/ajax-test');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -254,8 +237,7 @@ class ControllerTest extends TestCase
{
App::instance('request', $this->configAjaxRequestMock('onTest', 'ajax-result&ajax-second-result'));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/ajax-test');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -272,8 +254,7 @@ class ControllerTest extends TestCase
public function testBasicComponents()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/with-component')->getContent();
$page = PHPUnit_Framework_Assert::readAttribute($controller, 'page');
@ -301,8 +282,7 @@ ESC;
{
include_once base_path() . '/tests/fixtures/system/plugins/october/tester/components/Archive.php';
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/with-components')->getContent();
$page = PHPUnit_Framework_Assert::readAttribute($controller, 'page');
@ -331,8 +311,7 @@ ESC;
{
App::instance('request', $this->configAjaxRequestMock('testArchive::onTestAjax', 'ajax-result'));
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/with-component');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
@ -347,8 +326,7 @@ ESC;
public function testThemeUrl()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$url = $controller->themeUrl();

View File

@ -30,16 +30,14 @@ class ThemeTest extends TestCase
public function testGetPath()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$this->assertEquals(base_path().'/tests/fixtures/cms/themes/test', $theme->getPath());
}
public function testListPages()
{
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$pages = $theme->listPages();
$this->assertInternalType('array', $pages);

View File

@ -167,8 +167,7 @@ class CombineAssetsTest extends TestCase
{
$this->markTestIncomplete('Unfinished.');
$theme = new Theme();
$theme->load('test');
$theme = Theme::load('test');
$controller = new Controller($theme);
$response = $controller->run('/combine/xxxxxxxxx');