diff --git a/config/testing/cms.php b/config/testing/cms.php index 557d48010..36fe39edd 100644 --- a/config/testing/cms.php +++ b/config/testing/cms.php @@ -87,4 +87,26 @@ return [ 'convertLineEndings' => true, + /* + |-------------------------------------------------------------------------- + | Local plugins path + |-------------------------------------------------------------------------- + | + | Specifies the absolute local plugins path. + | + */ + + 'pluginsPathLocal' => base_path().'/tests/fixtures/plugins', + + /* + |-------------------------------------------------------------------------- + | Local themes path + |-------------------------------------------------------------------------- + | + | Specifies the absolute local themes path. + | + */ + + 'themesPathLocal' => base_path().'/tests/fixtures/themes', + ]; diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml deleted file mode 100644 index b33b6fd0b..000000000 --- a/phpdoc.dist.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - docs - - - docs - - - modules - vendor/october/rain/src/October - - \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index 2223371a5..a6928a163 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,10 +14,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); $app['cache']->setDefaultDriver('array'); - $app->setLocale('en'); - $app->setPluginsPath(base_path().'/tests/fixtures/plugins'); - $app->setThemesPath(base_path().'/tests/fixtures/themes'); return $app; } diff --git a/tests/unit/cms/classes/ControllerTest.php b/tests/unit/cms/classes/ControllerTest.php index 804ee0046..ca4bb38a1 100644 --- a/tests/unit/cms/classes/ControllerTest.php +++ b/tests/unit/cms/classes/ControllerTest.php @@ -144,61 +144,67 @@ class ControllerTest extends TestCase return $requestMock; } + /** + * @expectedException Cms\Classes\CmsException + * @expectedExceptionMessage AJAX handler 'onNoHandler' was not found. + */ public function testAjaxHandlerNotFound() { Request::swap($this->configAjaxRequestMock('onNoHandler', '')); $theme = Theme::load('test'); $controller = new Controller($theme); + $controller->run('/ajax-test'); - $response = $controller->run('/ajax-test'); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + // + // This was the old approach, can remove this comment block if year >= 2017 + // - $this->assertInternalType('string', $response->getOriginalContent()); - $this->assertEquals(500, $response->getStatusCode()); - $this->assertEquals("AJAX handler 'onNoHandler' was not found.", $response->getOriginalContent()); + // $response = $controller->run('/ajax-test'); + // $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + + // $this->assertInternalType('string', $response->getOriginalContent()); + // $this->assertEquals(500, $response->getStatusCode()); + // $this->assertEquals("AJAX handler 'onNoHandler' was not found.", $response->getOriginalContent()); } + /** + * @expectedException Cms\Classes\CmsException + * @expectedExceptionMessage Invalid AJAX handler name: delete. + */ public function testAjaxInvalidHandlerName() { Request::swap($this->configAjaxRequestMock('delete')); $theme = Theme::load('test'); $controller = new Controller($theme); - $response = $controller->run('/ajax-test'); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - - $this->assertInternalType('string', $response->getOriginalContent()); - $this->assertEquals(500, $response->getStatusCode()); - $this->assertEquals('Invalid AJAX handler name: delete.', $response->getOriginalContent()); + $controller->run('/ajax-test'); } + /** + * @expectedException Cms\Classes\CmsException + * @expectedExceptionMessage Invalid partial name: p:artial. + */ public function testAjaxInvalidPartial() { Request::swap($this->configAjaxRequestMock('onTest', 'p:artial')); $theme = Theme::load('test'); $controller = new Controller($theme); - $response = $controller->run('/ajax-test'); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - - $this->assertInternalType('string', $response->getOriginalContent()); - $this->assertEquals(500, $response->getStatusCode()); - $this->assertEquals('Invalid partial name: p:artial.', $response->getOriginalContent()); + $controller->run('/ajax-test'); } + /** + * @expectedException Cms\Classes\CmsException + * @expectedExceptionMessage The partial 'partial' is not found. + */ public function testAjaxPartialNotFound() { Request::swap($this->configAjaxRequestMock('onTest', 'partial')); $theme = Theme::load('test'); $controller = new Controller($theme); - $response = $controller->run('/ajax-test'); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - - $this->assertInternalType('string', $response->getOriginalContent()); - $this->assertEquals(500, $response->getStatusCode()); - $this->assertEquals("The partial 'partial' is not found.", $response->getOriginalContent()); + $controller->run('/ajax-test'); } public function testPageAjax() @@ -332,10 +338,10 @@ ESC; $controller = new Controller($theme); $url = $controller->themeUrl(); - $this->assertEquals('/tests/fixtures/themes/test', $url); + $this->assertEquals('http://localhost/themes/test', $url); $url = $controller->themeUrl('foo/bar.css'); - $this->assertEquals('/tests/fixtures/themes/test/foo/bar.css', $url); + $this->assertEquals('http://localhost/themes/test/foo/bar.css', $url); // // These tests seem to bear different results diff --git a/tests/unit/phpunit.xml b/tests/unit/phpunit.xml index a5415e7e5..b56a17834 100644 --- a/tests/unit/phpunit.xml +++ b/tests/unit/phpunit.xml @@ -15,4 +15,9 @@ ./ + + + + + \ No newline at end of file diff --git a/tests/unit/system/classes/CombineAssetsTest.php b/tests/unit/system/classes/CombineAssetsTest.php index 353ee4e6b..348f44cbd 100644 --- a/tests/unit/system/classes/CombineAssetsTest.php +++ b/tests/unit/system/classes/CombineAssetsTest.php @@ -70,13 +70,24 @@ class CombineAssetsTest extends TestCase public function testCombine() { $combiner = CombineAssets::instance(); - $url = $combiner->combine(['assets/css/style1.css', 'assets/css/style2.css'], '/tests/fixtures/themes/test'); - $this->assertNotNull($url); - $this->assertRegExp('/\w+[-]\d+/i', $url); // Must contain hash-number - $url = $combiner->combine(['assets/js/script1.js', 'assets/js/script2.js'], '/tests/fixtures/themes/test'); + $url = $combiner->combine([ + 'assets/css/style1.css', + 'assets/css/style2.css' + ], + base_path().'/tests/fixtures/themes/test' + ); $this->assertNotNull($url); - $this->assertRegExp('/\w+[-]\d+/i', $url); // Must contain hash-number + $this->assertRegExp('/\w+[-]\d+/i', $url); // Must contain hash-number + + $url = $combiner->combine([ + 'assets/js/script1.js', + 'assets/js/script2.js' + ], + base_path().'/tests/fixtures/themes/test' + ); + $this->assertNotNull($url); + $this->assertRegExp('/\w+[-]\d+/i', $url); // Must contain hash-number } public function testPrepareRequest() @@ -130,10 +141,10 @@ class CombineAssetsTest extends TestCase public function testMakeCacheId() { $sampleResources = ['assets/css/style1.css', 'assets/css/style2.css']; - $samplePath = '/tests/fixtures/Cms/themes/test'; + $samplePath = base_path().'/tests/fixtures/cms/themes/test'; $combiner = CombineAssets::instance(); - self::setProtectedProperty($combiner, 'path', $samplePath); + self::setProtectedProperty($combiner, 'localPath', $samplePath); $value = self::callProtectedMethod($combiner, 'makeCacheId', [$sampleResources]); $this->assertEquals(md5($samplePath.implode('|', $sampleResources)), $value);