jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/349418 )
Change subject: BSStateBar: Added BSApiStateBarTasksTest phpunit test
......................................................................
BSStateBar: Added BSApiStateBarTasksTest phpunit test
PatchSet2: implemented changes referenced by mglaser
PatchSet4: adding extra groups
Change-Id: I649330454a3bdf4f73570e498dcd0797d15d4f70
---
A StateBar/tests/phpunit/BSApiStateBarTasksTest.php
1 file changed, 67 insertions(+), 0 deletions(-)
Approvals:
Mglaser: Looks good to me, approved
jenkins-bot: Verified
diff --git a/StateBar/tests/phpunit/BSApiStateBarTasksTest.php
b/StateBar/tests/phpunit/BSApiStateBarTasksTest.php
new file mode 100644
index 0000000..28a32fe
--- /dev/null
+++ b/StateBar/tests/phpunit/BSApiStateBarTasksTest.php
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @group medium
+ * @group Database
+ * @group API
+ * @group BlueSpice
+ * @group BlueSpiceExtensions
+ * @group BlueSpiceStateBar
+ */
+class BSApiStateBarTasksTest extends BSApiTasksTestBase {
+ protected function setUp() {
+ parent::setUp();
+
+ //Statebar get it's context from
BSApiTasks::getContext()->getWikiPage()
+ //so we need to manually reset the context and inject our test
title
+ RequestContext::resetMain();
+ $GLOBALS['wgTitle'] = Title::newFromText(
"StatebarUnitTestPage" );
+ //Clear the BSStateBarBeforeBodyViewAdd to have always same
environment
+ $GLOBALS['wgHooks']['BSStateBarBeforeBodyViewAdd'] = [];
+ }
+
+ protected function getModuleName () {
+ return 'bs-statebar-tasks';
+ }
+ public function addDBDataOnce() {
+ $this->insertPage( 'StatebarUnitTestPage', "Statebar test page"
);
+ }
+ function getTokens () {
+ return $this->getTokenList( self::$users[ 'sysop' ] );
+ }
+
+ public function testFailCollectBodyViews() {
+ $oData = $this->executeTask(
+ 'collectBodyViews',
+ []
+ );
+
+ $this->assertTrue( $oData->success );
+ $this->assertArrayEquals( [], $oData->payload );
+ }
+
+ public function testCollectBodyViews() {
+ $GLOBALS['wgHooks']['BSStateBarBeforeBodyViewAdd'][]
+ = function( $oStateBar, &$aBodyViews, $oUser, $oTitle )
{
+ $aBodyViews[] = new
StateBarTasksTestViewStateBarBodyElement();
+ };
+ $oData = $this->executeTask(
+ 'collectBodyViews',
+ []
+ );
+
+ $this->assertTrue( $oData->success );
+ $this->assertArrayHasKey( 'views', $oData->payload );
+ $this->assertArrayHasKey( 0, $oData->payload['views'] );
+ $this->assertEquals(
+ 'StateBarTasksTestViewStateBarBodyElement',
+ $oData->payload['views'][0]
+ );
+ }
+}
+
+class StateBarTasksTestViewStateBarBodyElement extends ViewStateBarBodyElement
{
+ public function execute( $param = false ) {
+ return 'StateBarTasksTestViewStateBarBodyElement';
+ }
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/349418
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I649330454a3bdf4f73570e498dcd0797d15d4f70
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Pwirth <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits