themeUrl(); $this->assertEquals(url('/themes/test'), $url); $url = $controller->themeUrl('foo/bar.css'); $this->assertEquals(url('/themes/test/foo/bar.css'), $url); // // These tests seem to bear different results // // $url = $controller->themeUrl(['assets/css/style1.css', 'assets/css/style2.css']); // $url = substr($url, 0, strpos($url, '-')); // $this->assertEquals('/combine/88634b8fa6f4f6442ce830d38296640a', $url); // $url = $controller->themeUrl(['assets/js/script1.js', 'assets/js/script2.js']); // $url = substr($url, 0, strpos($url, '-')); // $this->assertEquals('/combine/860afc990164a60a8e90682d04da27ee', $url); } public function test404() { /* * Test the built-in 404 page */ $theme = Theme::load('apitest'); $controller = new Controller($theme); $response = $controller->run('/some-page-that-doesnt-exist'); $this->assertNotEmpty($response); $this->assertInstanceOf('\Illuminate\Http\Response', $response); ob_start(); include base_path().'/modules/cms/views/404.php'; $page404Content = ob_get_contents(); ob_end_clean(); $this->assertEquals($page404Content, $response->getContent()); /* * Test the theme 404 page */ $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/some-page-that-doesnt-exist'); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); $content = $response->getContent(); $this->assertIsString($content); $this->assertEquals('
Page not found
', $content); } public function testRoot() { /* * Test the / route and the fallback layout */ $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/'); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); $content = $response->getContent(); $this->assertIsString($content); $this->assertEquals('Hey
Hey PAGE PARTIAL Homer Simpson A partial
Hey PAGE CONTENT A content
Hey PAGE CONTENT
This page uses components.
Post Content #1
Second Post Content
ESC; $this->assertEquals($content, $response); $this->assertEquals(69, $component->property('posts-per-page')); $this->assertEquals('Blog Archive Dummy Component', $details['name']); $this->assertEquals('Displays an archive of blog posts.', $details['description']); } public function testComponentAliases() { include_once base_path() . '/tests/fixtures/plugins/october/tester/components/Archive.php'; $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/with-components')->getContent(); $page = self::getProtectedProperty($controller, 'page'); $this->assertArrayHasKey('firstAlias', $page->components); $this->assertArrayHasKey('secondAlias', $page->components); $component = $page->components['firstAlias']; $component2 = $page->components['secondAlias']; $content = <<This page uses components.
Post Content #1
Second Post Content
ESC; $this->assertEquals($content, $response); $this->assertEquals(6, $component->property('posts-per-page')); $this->assertEquals(9, $component2->property('posts-per-page')); } public function testComponentAjax() { Request::swap($this->configAjaxRequestMock('testArchive::onTestAjax', 'ajax-result')); $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/with-component'); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); $content = $response->getOriginalContent(); $this->assertIsArray($content); $this->assertEquals(200, $response->getStatusCode()); $this->assertCount(1, $content); $this->assertArrayHasKey('ajax-result', $content); $this->assertEquals('page', $content['ajax-result']); } public function testComponentClassNotFound() { $this->expectException(\October\Rain\Exception\SystemException::class); $this->expectExceptionMessageMatches('/is\snot\sregistered\sfor\sthe\scomponent/'); $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/no-component-class')->getContent(); } public function testSoftComponentClassNotFound() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/no-soft-component-class')->getContent(); $this->assertEquals('Hey
', $response); } public function testSoftComponentClassFound() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/with-soft-component-class')->getContent(); $page = $controller->getPage(); $this->assertArrayHasKey('testArchive', $page->components); $component = $page->components['testArchive']; $details = $component->componentDetails(); $content = <<This page uses components.
Post Content #1
Second Post Content
ESC; $this->assertEquals($content, $response); $this->assertEquals(69, $component->property('posts-per-page')); $this->assertEquals('Blog Archive Dummy Component', $details['name']); $this->assertEquals('Displays an archive of blog posts.', $details['description']); } public function testSoftComponentWithAliasClassFound() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/with-soft-component-class-alias')->getContent(); $page = $controller->getPage(); $this->assertArrayHasKey('someAlias', $page->components); $component = $page->components['someAlias']; $details = $component->componentDetails(); $content = <<This page uses components.
Post Content #1
Second Post Content
ESC; $this->assertEquals($content, $response); $this->assertEquals(69, $component->property('posts-per-page')); $this->assertEquals('Blog Archive Dummy Component', $details['name']); $this->assertEquals('Displays an archive of blog posts.', $details['description']); } public function testComponentNotFound() { // // This test should probably be throwing an exception... -sg // $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/no-component')->getContent(); $this->assertEquals('Hey
', $response); } public function testComponentPartial() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/component-partial')->getContent(); $this->assertEquals('DEFAULT MARKUP: I am a post yay
', $response); } public function testComponentPartialAliasOverride() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/component-partial-alias-override')->getContent(); // // Testing case sensitivity // // Component alias: overRide1 // Target path: partials\override1\default.htm // $this->assertEquals('I am an override alias partial! Yay
', $response); } public function testComponentPartialOverride() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/component-partial-override')->getContent(); // // Testing case sensitivity // // Component code: testPost // Target path: partials\testpost\default.htm // $this->assertEquals('I am an override partial! Yay
', $response); } public function testComponentPartialNesting() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/component-partial-nesting')->getContent(); $content = <<DEFAULT MARKUP: I am a post yay
I am another post, deep down
Insert post here
ESC; $this->assertEquals($content, $response); } public function testComponentWithOnRender() { $theme = Theme::load('test'); $controller = new Controller($theme); $response = $controller->run('/component-custom-render')->getContent(); $content = <<