Mglaser has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357773 )

Change subject: PageAssignments: reset assignments table after test
......................................................................

PageAssignments: reset assignments table after test

If not, following tests might break because of an unexpected state.
Also added failure notices to asserts.

Change-Id: I7aa7e838e82ca856e9ebe1f67a9641e2a778d87f
---
M PageAssignments/tests/phpunit/BSApiPageAssignmentTasksTest.php
1 file changed, 20 insertions(+), 15 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/73/357773/1

diff --git a/PageAssignments/tests/phpunit/BSApiPageAssignmentTasksTest.php 
b/PageAssignments/tests/phpunit/BSApiPageAssignmentTasksTest.php
index af3666d..579463b 100644
--- a/PageAssignments/tests/phpunit/BSApiPageAssignmentTasksTest.php
+++ b/PageAssignments/tests/phpunit/BSApiPageAssignmentTasksTest.php
@@ -9,6 +9,9 @@
  * @group BlueSpicePageAssignments
  */
 class BSApiPageAssignmentTasksTest extends BSApiTasksTestBase {
+
+       protected $tablesUsed = [ 'bs_pageassignments' ];
+
        protected function getModuleName () {
                return 'bs-pageassignment-tasks';
        }
@@ -29,13 +32,14 @@
                        )
                );
 
-               $this->assertTrue( $oData->success );
+               $this->assertTrue( $oData->success, "API returned failure 
state" );
 
                $this->assertSelect(
                        'bs_pageassignments',
                        array( 'pa_assignee_key', 'pa_assignee_type' ),
                        array( 'pa_page_id = 1' ),
-                       array(  array( 'UTSysop', 'user' ), array( 'sysop', 
'group' ) )
+                       array(  array( 'UTSysop', 'user' ), array( 'sysop', 
'group' ) ),
+                       "Assignment was not added to database"
                );
 
                $oData = $this->executeTask(
@@ -47,13 +51,14 @@
                        )
                );
 
-               $this->assertTrue( $oData->success );
+               $this->assertTrue( $oData->success, "API returned failure 
state" );
 
                $this->assertSelect(
                        'bs_pageassignments',
                        array( 'pa_assignee_key', 'pa_assignee_type' ),
                        array( 'pa_page_id = 1' ),
-                       array()
+                       array(),
+                       "Assignment was not removed from database"
                );
        }
 
@@ -69,7 +74,7 @@
                        )
                );
 
-               $this->assertTrue( $oData->success );
+               $this->assertTrue( $oData->success, "API returned failure 
state" );
 
                $oData = $this->executeTask(
                        'getForPage',
@@ -78,17 +83,17 @@
                        )
                );
 
-               $this->assertTrue( $oData->success );
-               $this->assertArrayHasKey( 0, $oData->payload );
-               $this->assertArrayHasKey( 1, $oData->payload );
+               $this->assertTrue( $oData->success, "API returned failure 
state" );
+               $this->assertArrayHasKey( 0, $oData->payload, "No assignment 
was returned" );
+               $this->assertArrayHasKey( 1, $oData->payload, "Second 
assignment was not returned" );
 
                $aAssignment = $oData->payload[0];
-               $this->assertArrayHasKey( 'type', $aAssignment );
-               $this->assertEquals( 'user', $aAssignment['type'] );
-               $this->assertArrayHasKey( 'id', $aAssignment );
-               $this->assertEquals( 'user/UTSysop', $aAssignment['id'] );
-               $this->assertArrayHasKey( 'text', $aAssignment );
-               $this->assertEquals( 'UTSysop', $aAssignment['text'] );
-               $this->assertArrayHasKey( 'anchor', $aAssignment );
+               $this->assertArrayHasKey( 'type', $aAssignment, "Assignment 
type is missing" );
+               $this->assertEquals( 'user', $aAssignment['type'], "Assignment 
type is not 'user'" );
+               $this->assertArrayHasKey( 'id', $aAssignment, "Assignment id is 
missing" );
+               $this->assertEquals( 'user/UTSysop', $aAssignment['id'], 
"Assignment id is not 'user/UTSysop'" );
+               $this->assertArrayHasKey( 'text', $aAssignment, "Assignment 
text is missing" );
+               $this->assertEquals( 'UTSysop', $aAssignment['text'], 
"Assignment text is not 'UTSysop'" );
+               $this->assertArrayHasKey( 'anchor', $aAssignment, "Assignment 
anchor is missing" );
        }
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/357773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7aa7e838e82ca856e9ebe1f67a9641e2a778d87f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Mglaser <gla...@hallowelt.biz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to