[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [websites/paste-kde-org] app/tests/steps: Add test cases for list controller
From: Sayak Banerjee <sayakb () kde ! org>
Date: 2014-06-08 8:30:03
Message-ID: E1WtYUN-0006d6-Gg () scm ! kde ! org
[Download RAW message or body]
Git commit d852bda9bb341de44e2c6460ca1b13b0af010d41 by Sayak Banerjee.
Committed on 08/06/2014 at 08:29.
Pushed by sayakb into branch 'master'.
Add test cases for list controller
M +5 -5 app/tests/steps/CreateTest.php
A +104 -0 app/tests/steps/ListTest.php
M +1 -1 app/tests/steps/ShowTest.php
http://commits.kde.org/websites/paste-kde-org/d852bda9bb341de44e2c6460ca1b13b0af010d41
diff --git a/app/tests/steps/CreateTest.php b/app/tests/steps/CreateTest.php
index bd64844..f154cf9 100755
--- a/app/tests/steps/CreateTest.php
+++ b/app/tests/steps/CreateTest.php
@@ -41,12 +41,12 @@ class CreateTest extends StickyNotesTestCase {
*/
public function testPostCreatePublic()
{
- // Pass only required parameters and allow Sticky Notes
- // to default the rest
+ $this->be(User::first());
+
$response = $this->action('POST', 'CreateController@postCreate', array(
- 'title' => 'UnitTest::Title',
- 'data' => 'UnitTest::Data',
- 'language' => 'text',
+ 'title' => 'UnitTest::Title',
+ 'data' => 'UnitTest::Data',
+ 'language' => 'text',
));
$this->assertRedirectedTo($response->getTargetUrl());
diff --git a/app/tests/steps/ListTest.php b/app/tests/steps/ListTest.php
new file mode 100755
index 0000000..9859f1d
--- /dev/null
+++ b/app/tests/steps/ListTest.php
@@ -0,0 +1,104 @@
+<?php
+
+/**
+ * Sticky Notes
+ *
+ * An open source lightweight pastebin application
+ *
+ * @package StickyNotes
+ * @author Sayak Banerjee
+ * @copyright (c) 2014 Sayak Banerjee <mail@sayakbanerjee.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * @link http://sayakbanerjee.com/sticky-notes
+ * @since Version 1.7
+ * @filesource
+ */
+
+/**
+ * ListTest
+ *
+ * Unit test cases for ListController
+ *
+ * @package StickyNotes
+ * @subpackage UnitTests
+ * @author Sayak Banerjee
+ */
+class ListTest extends StickyNotesTestCase {
+
+ /**
+ * Tests the getAll method of the controller
+ */
+ public function testGetAll()
+ {
+ $this->action('GET', 'ListController@getAll');
+
+ $this->assertResponseOk();
+ }
+
+ /**
+ * Tests the getTrending method of the controller
+ */
+ public function testGetTrending()
+ {
+ $this->action('GET', 'ListController@getTrending');
+
+ $this->assertResponseOk();
+ }
+
+ /**
+ * Tests the getUserPastes method of the controller
+ */
+ public function testGetUserPastes()
+ {
+ $this->be(User::first());
+
+ $this->action('GET', 'ListController@getUserPastes', array(
+ 'userid' => 'u1',
+ ));
+
+ $this->assertResponseOk();
+ }
+
+ /**
+ * Tests the getSearch method of the controller
+ */
+ public function testGetSearch()
+ {
+ $this->action('GET', 'ListController@getSearch', array(
+ 'q' => 'UnitTest',
+ ));
+
+ $this->assertResponseOk();
+ }
+
+ /**
+ * Tests the postSearch method of the controller
+ */
+ public function testPostSearch()
+ {
+ $this->action('POST', 'ListController@postSearch', array(
+ 'search' => 'UnitTest',
+ ));
+
+ $this->assertRedirectedTo('search?q=UnitTest');
+ }
+
+ /**
+ * Tests the getFlagged method of the controller
+ */
+ public function testGetFlagged()
+ {
+ // Flag the first paste
+ Paste::where('id', 1)->update(array(
+ 'flagged' => 1,
+ ));
+
+ // Only admins have access to flags
+ $this->be(User::first());
+
+ $this->action('GET', 'ListController@getFlagged');
+
+ $this->assertResponseOk();
+ }
+
+}
diff --git a/app/tests/steps/ShowTest.php b/app/tests/steps/ShowTest.php
index ab00cdc..75b0eb8 100755
--- a/app/tests/steps/ShowTest.php
+++ b/app/tests/steps/ShowTest.php
@@ -66,7 +66,7 @@ class ShowTest extends StickyNotesTestCase {
{
$left = Revision::firstOrFail();
- $right = Paste::find($left->paste_id);
+ $right = Paste::findOrFail($left->paste_id);
$this->action('GET', 'ShowController@getDiff', array(
'oldKey' => $left->urlkey,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic