Mattflaschen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/248570
Change subject: Merge two PagerTest together
......................................................................
Merge two PagerTest together
Change-Id: I516c756fc2f672a02c00db3e3d27ea4795007830
---
M tests/phpunit/Data/Pager/PagerTest.php
D tests/phpunit/PagerTest.php
2 files changed, 93 insertions(+), 105 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/70/248570/1
diff --git a/tests/phpunit/Data/Pager/PagerTest.php
b/tests/phpunit/Data/Pager/PagerTest.php
index b24f436..f5512e3 100644
--- a/tests/phpunit/Data/Pager/PagerTest.php
+++ b/tests/phpunit/Data/Pager/PagerTest.php
@@ -7,6 +7,8 @@
use Flow\Data\BufferedCache;
use Flow\Data\Index\TopKIndex;
use Flow\Data\Pager\Pager;
+use Flow\Data\Pager\PagerPage;
+use Flow\Model\UUID;
use stdClass;
/**
@@ -518,4 +520,95 @@
return $om;
}
+
+ public function provideDataMakePagingLink() {
+ return array (
+ array(
+ $this->mockStorage(
+ array(
+ $this->mockTopicListEntry(),
+ $this->mockTopicListEntry(),
+ $this->mockTopicListEntry()
+ ),
+ UUID::create(),
+ array( 'topic_id' )
+ ),
+ array( 'topic_list_id' => '123456' ),
+ array( 'pager-limit' => 2, 'order' => 'desc',
'sort' => 'topic_id' ),
+ 'offset-id'
+ ),
+ array(
+ $this->mockStorage(
+ array(
+ $this->mockTopicListEntry(),
+ $this->mockTopicListEntry()
+ ),
+ UUID::create(),
+ array( 'workflow_last_update_timestamp'
)
+ ),
+ array( 'topic_list_id' => '123456' ),
+ array( 'pager-limit' => 1, 'order' => 'desc',
'sort' => 'workflow_last_update_timestamp', 'sortby' => 'updated' ),
+ 'offset'
+ )
+ );
+ }
+
+ /**
+ * @dataProvider provideDataMakePagingLink
+ */
+ public function testMakePagingLink( $storage, $query, $options,
$offsetKey ) {
+ $pager = new Pager( $storage, $query, $options );
+ $page = $pager->getPage();
+ $pagingOption = $page->getPagingLinksOptions();
+ foreach ( $pagingOption as $option ) {
+ $this->assertArrayHasKey( $offsetKey, $option );
+ $this->assertArrayHasKey( 'offset-dir', $option );
+ $this->assertArrayHasKey( 'limit', $option );
+ if ( isset( $options['sortby'] ) ) {
+ $this->assertArrayHasKey( 'sortby', $option );
+ }
+ }
+ }
+
+ /**
+ * Mock the storage
+ */
+ protected function mockStorage( $return, $offset, $sort ) {
+ $storage = $this->getMockBuilder( 'Flow\Data\ObjectManager' )
+ ->disableOriginalConstructor()
+ ->getMock();
+ $storage->expects( $this->any() )
+ ->method( 'find' )
+ ->will( $this->returnValue( $return ) );
+ $storage->expects( $this->any() )
+ ->method( 'serializeOffset' )
+ ->will( $this->returnValue( $offset ) );
+ $storage->expects( $this->any() )
+ ->method( 'getIndexFor' )
+ ->will( $this->returnValue( $this->mockIndex( $sort ) )
);
+ return $storage;
+ }
+
+ /**
+ * Mock TopicListEntry
+ */
+ protected function mockTopicListEntry() {
+ $entry = $this->getMockBuilder( 'Flow\Model\TopicListEntry' )
+ ->disableOriginalConstructor()
+ ->getMock();
+ return $entry;
+ }
+
+ /**
+ * Mock TopKIndex
+ */
+ protected function mockIndex( $sort ) {
+ $index = $this->getMockBuilder( 'Flow\Data\Index\TopKIndex' )
+ ->disableOriginalConstructor()
+ ->getMock();
+ $index->expects( $this->any() )
+ ->method( 'getSort' )
+ ->will( $this->returnValue( $sort ) );
+ return $index;
+ }
}
diff --git a/tests/phpunit/PagerTest.php b/tests/phpunit/PagerTest.php
deleted file mode 100644
index b4a4629..0000000
--- a/tests/phpunit/PagerTest.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-
-namespace Flow\Tests;
-
-use Flow\Data\Pager\PagerPage;
-use Flow\Data\Pager\Pager;
-use Flow\Model\UUID;
-
-/**
- * @group Flow
- */
-class PagerTest extends FlowTestCase {
-
- public function provideDataMakePagingLink() {
- return array (
- array(
- $this->mockStorage(
- array(
- $this->mockTopicListEntry(),
- $this->mockTopicListEntry(),
- $this->mockTopicListEntry()
- ),
- UUID::create(),
- array( 'topic_id' )
- ),
- array( 'topic_list_id' => '123456' ),
- array( 'pager-limit' => 2, 'order' => 'desc',
'sort' => 'topic_id' ),
- 'offset-id'
- ),
- array(
- $this->mockStorage(
- array(
- $this->mockTopicListEntry(),
- $this->mockTopicListEntry()
- ),
- UUID::create(),
- array( 'workflow_last_update_timestamp'
)
- ),
- array( 'topic_list_id' => '123456' ),
- array( 'pager-limit' => 1, 'order' => 'desc',
'sort' => 'workflow_last_update_timestamp', 'sortby' => 'updated' ),
- 'offset'
- )
- );
- }
-
- /**
- * @dataProvider provideDataMakePagingLink
- */
- public function testMakePagingLink( $storage, $query, $options,
$offsetKey ) {
- $pager = new Pager( $storage, $query, $options );
- $page = $pager->getPage();
- $pagingOption = $page->getPagingLinksOptions();
- foreach ( $pagingOption as $option ) {
- $this->assertArrayHasKey( $offsetKey, $option );
- $this->assertArrayHasKey( 'offset-dir', $option );
- $this->assertArrayHasKey( 'limit', $option );
- if ( isset( $options['sortby'] ) ) {
- $this->assertArrayHasKey( 'sortby', $option );
- }
- }
- }
-
- /**
- * Mock the storage
- */
- protected function mockStorage( $return, $offset, $sort ) {
- $storage = $this->getMockBuilder( 'Flow\Data\ObjectManager' )
- ->disableOriginalConstructor()
- ->getMock();
- $storage->expects( $this->any() )
- ->method( 'find' )
- ->will( $this->returnValue( $return ) );
- $storage->expects( $this->any() )
- ->method( 'serializeOffset' )
- ->will( $this->returnValue( $offset ) );
- $storage->expects( $this->any() )
- ->method( 'getIndexFor' )
- ->will( $this->returnValue( $this->mockIndex( $sort ) )
);
- return $storage;
- }
-
- /**
- * Mock TopicListEntry
- */
- protected function mockTopicListEntry() {
- $entry = $this->getMockBuilder( 'Flow\Model\TopicListEntry' )
- ->disableOriginalConstructor()
- ->getMock();
- return $entry;
- }
-
- /**
- * Mock TopKIndex
- */
- protected function mockIndex( $sort ) {
- $index = $this->getMockBuilder( 'Flow\Data\Index\TopKIndex' )
- ->disableOriginalConstructor()
- ->getMock();
- $index->expects( $this->any() )
- ->method( 'getSort' )
- ->will( $this->returnValue( $sort ) );
- return $index;
- }
-
-}
--
To view, visit https://gerrit.wikimedia.org/r/248570
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I516c756fc2f672a02c00db3e3d27ea4795007830
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits