diff options
Diffstat (limited to 'tests/Unit/Db/ItemMapperAfterTest.php')
-rw-r--r-- | tests/Unit/Db/ItemMapperAfterTest.php | 139 |
1 files changed, 8 insertions, 131 deletions
diff --git a/tests/Unit/Db/ItemMapperAfterTest.php b/tests/Unit/Db/ItemMapperAfterTest.php index 5c91fa00d..eccebbcf5 100644 --- a/tests/Unit/Db/ItemMapperAfterTest.php +++ b/tests/Unit/Db/ItemMapperAfterTest.php @@ -62,11 +62,10 @@ class ItemMapperAfterTest extends MapperTestUtility ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); - $this->builder->expects($this->exactly(4)) + $this->builder->expects($this->exactly(3)) ->method('andWhere') ->withConsecutive( ['items.last_modified >= :updatedSince'], - ['items.shared_by = \'\''], ['feeds.user_id = :userId'], ['feeds.id = :feedId'], ['feeds.deleted_at = 0'] @@ -128,11 +127,10 @@ class ItemMapperAfterTest extends MapperTestUtility ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); - $this->builder->expects($this->exactly(5)) + $this->builder->expects($this->exactly(4)) ->method('andWhere') ->withConsecutive( ['items.last_modified >= :updatedSince'], - ['items.shared_by = \'\''], ['feeds.user_id = :userId'], ['feeds.id = :feedId'], ['feeds.deleted_at = 0'], @@ -203,11 +201,10 @@ class ItemMapperAfterTest extends MapperTestUtility ) ->will($this->returnSelf()); - $this->builder->expects($this->exactly(4)) + $this->builder->expects($this->exactly(3)) ->method('andWhere') ->withConsecutive( ['items.last_modified >= :updatedSince'], - ['items.shared_by = \'\''], ['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['folders.id = :folderId'] @@ -272,11 +269,10 @@ class ItemMapperAfterTest extends MapperTestUtility ) ->will($this->returnSelf()); - $this->builder->expects($this->exactly(5)) + $this->builder->expects($this->exactly(4)) ->method('andWhere') ->withConsecutive( ['items.last_modified >= :updatedSince'], - ['items.shared_by = \'\''], ['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['folders.id = :folderId'], @@ -323,121 +319,6 @@ class ItemMapperAfterTest extends MapperTestUtility $this->assertEquals([Item::fromRow(['id' => 4])], $result); } - public function testFindAllSharedAfter() - { - $this->db->expects($this->once()) - ->method('getQueryBuilder') - ->willReturn($this->builder); - - $this->builder->expects($this->once()) - ->method('select') - ->with('items.*') - ->will($this->returnSelf()); - - $this->builder->expects($this->once()) - ->method('from') - ->with('news_items', 'items') - ->will($this->returnSelf()); - - $this->builder->expects($this->exactly(2)) - ->method('andWhere') - ->withConsecutive( - ['items.last_modified >= :updatedSince'], - ['items.shared_with = :sharedWith'] - ) - ->will($this->returnSelf()); - - $this->builder->expects($this->exactly(1)) - ->method('setParameters') - ->with([ - 'updatedSince' => 1610903351, - 'sharedWith' => 'jack', - ]) - ->will($this->returnSelf()); - - $this->builder->expects($this->once()) - ->method('orderBy') - ->with('items.last_modified', 'DESC') - ->will($this->returnSelf()); - - $this->builder->expects($this->once()) - ->method('addOrderBy') - ->with('items.id', 'DESC') - ->willReturnSelf(); - - $this->builder->expects($this->once()) - ->method('execute') - ->will($this->returnValue($this->cursor)); - - $this->cursor->expects($this->exactly(2)) - ->method('fetch') - ->willReturnOnConsecutiveCalls( - ['id' => 4], - false - ); - - $result = $this->class->findAllSharedAfter('jack', 1610903351, false); - $this->assertEquals([Item::fromRow(['id' => 4])], $result); - } - - public function testFindAllSharedAfterHideRead() - { - $this->db->expects($this->once()) - ->method('getQueryBuilder') - ->willReturn($this->builder); - - $this->builder->expects($this->once()) - ->method('select') - ->with('items.*') - ->will($this->returnSelf()); - - $this->builder->expects($this->once()) - ->method('from') - ->with('news_items', 'items') - ->will($this->returnSelf()); - - $this->builder->expects($this->exactly(3)) - ->method('andWhere') - ->withConsecutive( - ['items.last_modified >= :updatedSince'], - ['items.shared_with = :sharedWith'], - ['items.unread = 1'] - ) - ->will($this->returnSelf()); - - $this->builder->expects($this->exactly(1)) - ->method('setParameters') - ->with([ - 'updatedSince' => 1610903351, - 'sharedWith' => 'jack' - ]) - ->will($this->returnSelf()); - - $this->builder->expects($this->once()) - ->method('orderBy') - ->with('items.last_modified', 'DESC') - ->will($this->returnSelf()); - - $this->builder->expects($this->once()) - ->method('addOrderBy') - ->with('items.id', 'DESC') - ->willReturnSelf(); - - $this->builder->expects($this->once()) - ->method('execute') - ->will($this->returnValue($this->cursor)); - - $this->cursor->expects($this->exactly(2)) - ->method('fetch') - ->willReturnOnConsecutiveCalls( - ['id' => 4], - false - ); - - $result = $this->class->findAllSharedAfter('jack', 1610903351, true); - $this->assertEquals([Item::fromRow(['id' => 4])], $result); - } - public function testFindAllAfterUnread() { $this->db->expects($this->once()) @@ -464,7 +345,7 @@ class ItemMapperAfterTest extends MapperTestUtility ->withConsecutive( ['items.last_modified >= :updatedSince'], ['feeds.deleted_at = 0'], - ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'], + ['feeds.user_id = :userId'], ['items.unread = :unread'] ) ->will($this->returnSelf()); @@ -474,7 +355,6 @@ class ItemMapperAfterTest extends MapperTestUtility ->with([ 'updatedSince' => 1610903351, 'userId' => 'jack', - 'sharedWith' => 'jack' ]) ->will($this->returnSelf()); @@ -534,7 +414,7 @@ class ItemMapperAfterTest extends MapperTestUtility ->withConsecutive( ['items.last_modified >= :updatedSince'], ['feeds.deleted_at = 0'], - ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'], + ['feeds.user_id = :userId'], ['items.starred = :starred'] ) ->will($this->returnSelf()); @@ -544,7 +424,6 @@ class ItemMapperAfterTest extends MapperTestUtility ->with([ 'updatedSince' => 1610903351, 'userId' => 'jack', - 'sharedWith' => 'jack' ]) ->will($this->returnSelf()); @@ -604,7 +483,7 @@ class ItemMapperAfterTest extends MapperTestUtility ->withConsecutive( ['items.last_modified >= :updatedSince'], ['feeds.deleted_at = 0'], - ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'] + ['feeds.user_id = :userId'] ) ->will($this->returnSelf()); @@ -613,7 +492,6 @@ class ItemMapperAfterTest extends MapperTestUtility ->with([ 'updatedSince' => 1610903351, 'userId' => 'jack', - 'sharedWith' => 'jack' ]) ->will($this->returnSelf()); @@ -671,7 +549,7 @@ class ItemMapperAfterTest extends MapperTestUtility ->withConsecutive( ['items.last_modified >= :updatedSince'], ['feeds.deleted_at = 0'], - ['(feeds.user_id = :userId AND items.shared_by = \'\') OR items.shared_with = :sharedWith'] + ['feeds.user_id = :userId'] ) ->will($this->returnSelf()); @@ -680,7 +558,6 @@ class ItemMapperAfterTest extends MapperTestUtility ->with([ 'updatedSince' => 1610903351, 'userId' => 'jack', - 'sharedWith' => 'jack' ]) ->will($this->returnSelf()); |