This repository has been archived by the owner on Jan 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 812
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6667d71
commit cbd3b82
Showing
3 changed files
with
238 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of Bootstrap CMS by Graham Campbell. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
*/ | ||
|
||
namespace GrahamCampbell\Tests\BootstrapCMS\Acceptance; | ||
|
||
/** | ||
* This is the caching test class. | ||
* | ||
* @group caching | ||
* | ||
* @author Graham Campbell <[email protected]> | ||
* @copyright 2013-2014 Graham Campbell | ||
* @license <https://github.com/GrahamCampbell/Bootstrap-CMS/blob/master/LICENSE.md> AGPL 3.0 | ||
*/ | ||
class CachingTest extends AbstractTestCase | ||
{ | ||
public function testIndex() | ||
{ | ||
$this->call('GET', 'caching'); | ||
|
||
$this->assertResponseOk(); | ||
$this->assertSee('Caching'); | ||
$this->assertSee('Caching controls coming soon...'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of Bootstrap CMS by Graham Campbell. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
*/ | ||
|
||
namespace GrahamCampbell\Tests\BootstrapCMS\Acceptance; | ||
|
||
use GrahamCampbell\BootstrapCMS\Facades\PostProvider; | ||
use GrahamCampbell\Credentials\Facades\Credentials; | ||
|
||
/** | ||
* This is the comment test class. | ||
* | ||
* @group comment | ||
* | ||
* @author Graham Campbell <[email protected]> | ||
* @copyright 2013-2014 Graham Campbell | ||
* @license <https://github.com/GrahamCampbell/Bootstrap-CMS/blob/master/LICENSE.md> AGPL 3.0 | ||
*/ | ||
class CommentTest extends AbstractTestCase | ||
{ | ||
public function testIndexFail() | ||
{ | ||
PostProvider::shouldReceive('find')->once()->with(1, array('id')); | ||
$content = $this->call('GET', 'blog/posts/1/comments')->getContent(); | ||
|
||
$this->assertResponseStatus(404); | ||
$this->assertEquals('{"success":false,"code":404,"msg":"The post you were viewing has been deleted.","url":"http:\/\/localhost\/blog\/posts"}', $content); | ||
} | ||
|
||
public function testIndexSuccess() | ||
{ | ||
$content = $this->call('GET', 'blog/posts/1/comments')->getContent(); | ||
|
||
$this->assertResponseOk(); | ||
$this->assertEquals('[{"comment_id":"1","comment_ver":"1"}]', $content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,41 +16,180 @@ | |
|
||
namespace GrahamCampbell\Tests\BootstrapCMS\Acceptance; | ||
|
||
use GrahamCampbell\Credentials\Facades\Credentials; | ||
|
||
/** | ||
* This is the page test class. | ||
* | ||
* @group acceptance | ||
* @group page | ||
* | ||
* @author Graham Campbell <[email protected]> | ||
* @copyright 2013-2014 Graham Campbell | ||
* @license <https://github.com/GrahamCampbell/Bootstrap-CMS/blob/master/LICENSE.md> AGPL 3.0 | ||
*/ | ||
class Pagetest extends AbstractTestCase | ||
class PageTest extends AbstractTestCase | ||
{ | ||
public function testIndex() | ||
{ | ||
$this->call('GET', '/'); | ||
|
||
$this->assertRedirectedTo('pages/home'); | ||
|
||
$this->callAgain('GET', 'pages'); | ||
|
||
$this->assertRedirectedTo('pages/home'); | ||
} | ||
|
||
// public function testCreate() | ||
// { | ||
// $this->login(); | ||
// $this->call('PUT', 'pages/create', array()); | ||
// $this->assertRedirectedTo('pages/create'); | ||
// } | ||
public function testCreate() | ||
{ | ||
$this->call('GET', 'pages/create'); | ||
|
||
$this->assertResponseOk(); | ||
$this->assertSee('Create Page'); | ||
} | ||
|
||
public function testStoreFail() | ||
{ | ||
Credentials::shouldReceive('getuser')->once()->andReturn((object) array('id' => 1)); | ||
|
||
$this->call('POST', 'pages'); | ||
|
||
$this->assertRedirectedTo('pages/create'); | ||
$this->assertSessionHasErrors(); | ||
$this->assertHasOldInput(); | ||
} | ||
|
||
public function testStoreSuccess() | ||
{ | ||
Credentials::shouldReceive('getuser')->once()->andReturn((object) array('id' => 1)); | ||
|
||
$this->call('POST', 'pages', array( | ||
'title' => 'New Page', | ||
'nav_title' => 'Herro', | ||
'slug' => 'foobar', | ||
'icon' => '', | ||
'body' => 'Why herro there!', | ||
'css' => '', | ||
'js' => '', | ||
'show_title' => 'on', | ||
'show_nav' => 'on' | ||
|
||
)); | ||
|
||
$this->assertRedirectedTo('pages/foobar'); | ||
$this->assertSessionHas('success'); | ||
} | ||
|
||
/** | ||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException | ||
* @expectedExceptionMessage Page Not Found | ||
*/ | ||
public function testShowFail() | ||
{ | ||
$this->call('GET', 'pages/error'); | ||
} | ||
|
||
public function testShowHome() | ||
public function testShowSuccess() | ||
{ | ||
$this->call('GET', 'pages/home'); | ||
|
||
$this->assertResponseOk(); | ||
$this->assertSee('Bootstrap CMS'); | ||
|
||
$this->callAgain('GET', 'pages/about'); | ||
|
||
$this->assertResponseOk(); | ||
$this->assertSee('This is the about page!'); | ||
} | ||
|
||
public function testShowAbout() | ||
public function testEditHome() | ||
{ | ||
$this->call('GET', 'pages/about'); | ||
$this->call('GET', 'pages/home/edit'); | ||
|
||
$this->assertResponseOk(); | ||
$this->assertSee('This is the about page!'); | ||
$this->assertSee('Edit Welcome'); | ||
} | ||
|
||
public function testUpdateFail() | ||
{ | ||
$this->call('PATCH', 'pages/home'); | ||
|
||
$this->assertRedirectedTo('pages/home/edit'); | ||
$this->assertSessionHasErrors(); | ||
$this->assertHasOldInput(); | ||
} | ||
|
||
public function testUpdateHomeUrl() | ||
{ | ||
$this->call('PATCH', 'pages/home', array( | ||
'title' => 'New Page', | ||
'nav_title' => 'Herro', | ||
'slug' => 'foobar', | ||
'icon' => '', | ||
'body' => 'Why herro there!', | ||
'css' => '', | ||
'js' => '', | ||
'show_title' => 'on', | ||
'show_nav' => 'on' | ||
|
||
)); | ||
|
||
$this->assertRedirectedTo('pages/home/edit'); | ||
$this->assertSessionHas('error'); | ||
$this->assertHasOldInput(); | ||
} | ||
|
||
public function testUpdateHomeNav() | ||
{ | ||
$this->call('PATCH', 'pages/home', array( | ||
'title' => 'New Page', | ||
'nav_title' => 'Herro', | ||
'slug' => 'home', | ||
'icon' => '', | ||
'body' => 'Why herro there!', | ||
'css' => '', | ||
'js' => '', | ||
'show_title' => 'on', | ||
'show_nav' => 'off' | ||
|
||
)); | ||
|
||
$this->assertRedirectedTo('pages/home/edit'); | ||
$this->assertSessionHas('error'); | ||
$this->assertHasOldInput(); | ||
} | ||
|
||
public function testUpdateSuccess() | ||
{ | ||
$this->call('PATCH', 'pages/home', array( | ||
'title' => 'New Page', | ||
'nav_title' => 'Herro', | ||
'slug' => 'home', | ||
'icon' => '', | ||
'body' => 'Why herro there!', | ||
'css' => '', | ||
'js' => '', | ||
'show_title' => 'on', | ||
'show_nav' => 'on' | ||
|
||
)); | ||
|
||
$this->assertRedirectedTo('pages/home'); | ||
$this->assertSessionHas('success'); | ||
} | ||
|
||
public function testDestroyFail() | ||
{ | ||
$this->call('DELETE', 'pages/home'); | ||
|
||
$this->assertRedirectedTo('pages/home'); | ||
$this->assertSessionHas('error'); | ||
} | ||
|
||
public function testDestroySuccess() | ||
{ | ||
$this->call('DELETE', 'pages/about'); | ||
|
||
$this->assertRedirectedTo('pages/home'); | ||
} | ||
} |