diff --git a/app/config/testing/cms.php b/app/config/testing/cms.php index 7343d99a2..181bada7d 100644 --- a/app/config/testing/cms.php +++ b/app/config/testing/cms.php @@ -96,4 +96,16 @@ return array( */ 'twigNoCache' => true, + + /* + |-------------------------------------------------------------------------- + | Convert Line Endings + |-------------------------------------------------------------------------- + | + | Determines if October should convert line endings from the windows style + | \r\n to the unix style \n. + | + */ + + 'convertLineEndings' => true, ); diff --git a/modules/cms/classes/SectionParser.php b/modules/cms/classes/SectionParser.php index 74027e3e0..a9e913684 100644 --- a/modules/cms/classes/SectionParser.php +++ b/modules/cms/classes/SectionParser.php @@ -1,5 +1,7 @@ getSettingsRecord() !== null; + return DbDongle::hasDatabase() && $this->getSettingsRecord() !== null; } /** diff --git a/modules/system/classes/SystemException.php b/modules/system/classes/SystemException.php index cad2361cd..b7d40c0f5 100644 --- a/modules/system/classes/SystemException.php +++ b/modules/system/classes/SystemException.php @@ -1,5 +1,6 @@ assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); - $this->assertFileEquals($referenceFilePath, $destFilePath); + $this->assertFileEqualsNormalized($referenceFilePath, $destFilePath); } public function testSaveMarkupAndSettings() @@ -187,7 +187,7 @@ class CmsCompoundObjectTest extends TestCase $this->assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); - $this->assertFileEquals($referenceFilePath, $destFilePath); + $this->assertFileEqualsNormalized($referenceFilePath, $destFilePath); } public function testSaveFull() @@ -195,8 +195,9 @@ class CmsCompoundObjectTest extends TestCase $theme = Theme::load('apitest'); $destFilePath = $theme->getPath().'/testobjects/compound.htm'; - if (file_exists($destFilePath)) + if (file_exists($destFilePath)) { unlink($destFilePath); + } $this->assertFileNotExists($destFilePath); @@ -213,6 +214,22 @@ class CmsCompoundObjectTest extends TestCase $this->assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); - $this->assertFileEquals($referenceFilePath, $destFilePath); + $this->assertFileEqualsNormalized($referenceFilePath, $destFilePath); } + + // + // Helpers + // + + protected function assertFileEqualsNormalized($expected, $actual) + { + $expected = file_get_contents($expected); + $expected = preg_replace('~\R~u', PHP_EOL, $expected); // Normalize EOL + + $actual = file_get_contents($actual); + $actual = preg_replace('~\R~u', PHP_EOL, $actual); // Normalize EOL + + $this->assertEquals($expected, $actual); + } + } \ No newline at end of file diff --git a/tests/unit/cms/classes/CmsObjectTest.php b/tests/unit/cms/classes/CmsObjectTest.php index f74193b16..481fc4a33 100644 --- a/tests/unit/cms/classes/CmsObjectTest.php +++ b/tests/unit/cms/classes/CmsObjectTest.php @@ -141,7 +141,7 @@ class CmsObjectTest extends TestCase /** * @expectedException \System\Classes\ApplicationException - * @expectedExceptionMessage The property "something" cannot be set + * @expectedExceptionMessage The property 'something' cannot be set */ public function testFillNotFillable() { diff --git a/tests/unit/cms/classes/CodeParserTest.php b/tests/unit/cms/classes/CodeParserTest.php index e87d79e1d..00799b932 100644 --- a/tests/unit/cms/classes/CodeParserTest.php +++ b/tests/unit/cms/classes/CodeParserTest.php @@ -253,10 +253,22 @@ class CodeParserTest extends TestCase $referenceFilePath = base_path().'/tests/fixtures/cms/reference/namespaces.php'; $this->assertFileExists($referenceFilePath); - $referenceContents = file_get_contents($referenceFilePath); + $referenceContents = $this->getContents($referenceFilePath); $referenceContents = str_replace('{className}', $info['className'], $referenceContents); - $this->assertEquals($referenceContents, file_get_contents($info['filePath'])); + $this->assertEquals($referenceContents, $this->getContents($info['filePath'])); } + + // + // Helpers + // + + protected function getContents($path) + { + $content = file_get_contents($path); + $content = preg_replace('~\R~u', PHP_EOL, $content); // Normalize EOL + return $content; + } + } \ No newline at end of file diff --git a/tests/unit/cms/classes/FileHelperTest.php b/tests/unit/cms/classes/FileHelperTest.php index 2b9075ea1..f8f66d324 100644 --- a/tests/unit/cms/classes/FileHelperTest.php +++ b/tests/unit/cms/classes/FileHelperTest.php @@ -28,7 +28,7 @@ class FileHelperTest extends TestCase $str = FileHelper::formatIniString($data); $this->assertNotEmpty($str); - $this->assertEquals(file_get_contents($path), $str); + $this->assertEquals($this->getContents($path), $str); $data = [ 'section' => [ @@ -47,7 +47,7 @@ class FileHelperTest extends TestCase $this->assertFileExists($path); $str = FileHelper::formatIniString($data); - $this->assertEquals(file_get_contents($path), $str); + $this->assertEquals($this->getContents($path), $str); $data = [ 'section' => [ @@ -75,6 +75,21 @@ class FileHelperTest extends TestCase $this->assertFileExists($path); $str = FileHelper::formatIniString($data); - $this->assertEquals(file_get_contents($path), $str); + $this->assertEquals($this->getContents($path), $str); } + + // + // Helpers + // + + protected function getContents($path) + { + $content = file_get_contents($path); + + // Normalize EOL + $content = preg_replace('~\R~u', PHP_EOL, $content); + + return $content; + } + } diff --git a/tests/unit/cms/classes/RouterTest.php b/tests/unit/cms/classes/RouterTest.php index b1d75936c..12c3c402f 100644 --- a/tests/unit/cms/classes/RouterTest.php +++ b/tests/unit/cms/classes/RouterTest.php @@ -6,11 +6,10 @@ use Cms\Classes\Theme; class RouterTest extends TestCase { protected static $theme = null; - + public static function setUpBeforeClass() { - self::$theme = new Theme(); - self::$theme->load('test'); + self::$theme = Theme::load('test'); } protected static function getMethod($name) @@ -28,7 +27,7 @@ class RouterTest extends TestCase $property->setAccessible(true); return $property; } - + public function testLoadUrlMap() { $method = self::getMethod('loadUrlMap'); diff --git a/tests/unit/cms/classes/ThemeTest.php b/tests/unit/cms/classes/ThemeTest.php index 3c5b65c20..f3192aa56 100644 --- a/tests/unit/cms/classes/ThemeTest.php +++ b/tests/unit/cms/classes/ThemeTest.php @@ -2,7 +2,7 @@ use Cms\Classes\Theme; -class ThemeTest extends TestCase +class ThemeTest extends TestCase { public function setUp() {