Skip to content

Commit 0a02734

Browse files
committed
Move DB mapper tests from unit to integration testing
Signed-off-by: Paul Schwörer <hello@paulschwoerer.de>
1 parent 7887f0a commit 0a02734

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

phpunit.integration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<filter>
33
<whitelist>
44
<directory suffix=".php">appinfo</directory>
5+
<directory suffix=".php">lib</directory>
56
<exclude>
6-
<directory suffix=".php">lib</directory>
77
<directory suffix=".php">templates</directory>
88
</exclude>
99
</whitelist>

tests/Unit/Mapper/FavoriteShareMapperTest.php renamed to tests/Integration/Db/FavoriteShareMapperTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*/
2424

25-
namespace tests\Unit\Mapper;
25+
namespace tests\Integration\Db;
2626

2727

2828
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
@@ -36,20 +36,20 @@ class FavoriteShareMapperTest extends TestCase {
3636
use DatabaseTransaction;
3737

3838
/* @var FavoriteShareMapper */
39-
private $favoriteShareMapper;
39+
private $mapper;
4040

4141
public function setUp(): void {
4242
parent::setUp();
4343

44-
$this->favoriteShareMapper = new FavoriteShareMapper(
44+
$this->mapper = new FavoriteShareMapper(
4545
OC::$server->getDatabaseConnection(),
4646
OC::$server->getSecureRandom()
4747
);
4848
}
4949

5050
public function testCreateByOwnerAndTokenIsSuccessful() {
5151
/* @var FavoriteShare */
52-
$share = $this->favoriteShareMapper->create("testUser", "testCategory");
52+
$share = $this->mapper->create("testUser", "testCategory");
5353

5454
$this->assertIsString($share->getToken());
5555
$this->assertEquals("testUser", $share->getOwner());
@@ -58,10 +58,10 @@ public function testCreateByOwnerAndTokenIsSuccessful() {
5858

5959
public function testFindByTokenIsSuccessful() {
6060
/* @var FavoriteShare */
61-
$shareExpected = $this->favoriteShareMapper->create("testUser", "testCategory");
61+
$shareExpected = $this->mapper->create("testUser", "testCategory");
6262

6363
/* @var FavoriteShare */
64-
$shareActual = $this->favoriteShareMapper->findByToken($shareExpected->getToken());
64+
$shareActual = $this->mapper->findByToken($shareExpected->getToken());
6565

6666
$this->assertEquals($shareExpected->getToken(), $shareActual->getToken());
6767
$this->assertEquals($shareExpected->getOwner(), $shareActual->getOwner());
@@ -70,10 +70,10 @@ public function testFindByTokenIsSuccessful() {
7070

7171
public function testFindByOwnerAndCategoryIsSuccessful() {
7272
/* @var FavoriteShare */
73-
$shareExpected = $this->favoriteShareMapper->create("testUser", "testCategory");
73+
$shareExpected = $this->mapper->create("testUser", "testCategory");
7474

7575
/* @var FavoriteShare */
76-
$shareActual = $this->favoriteShareMapper->findByOwnerAndCategory("testUser", "testCategory");
76+
$shareActual = $this->mapper->findByOwnerAndCategory("testUser", "testCategory");
7777

7878
$this->assertEquals($shareExpected->getToken(), $shareActual->getToken());
7979
$this->assertEquals($shareExpected->getOwner(), $shareActual->getOwner());
@@ -82,15 +82,15 @@ public function testFindByOwnerAndCategoryIsSuccessful() {
8282

8383
public function testFindAllByOwnerIsSuccessfulAndDoesNotContainOtherShares() {
8484
/* @var FavoriteShare */
85-
$share1 = $this->favoriteShareMapper->create("testUser", "testCategory1");
85+
$share1 = $this->mapper->create("testUser", "testCategory1");
8686

8787
/* @var FavoriteShare */
88-
$share2 = $this->favoriteShareMapper->create("testUser", "testCategory2");
88+
$share2 = $this->mapper->create("testUser", "testCategory2");
8989

90-
$this->favoriteShareMapper->create("testUser2", "testCategory");
90+
$this->mapper->create("testUser2", "testCategory");
9191

9292
/* @var array */
93-
$shares = $this->favoriteShareMapper->findAllByOwner("testUser");
93+
$shares = $this->mapper->findAllByOwner("testUser");
9494

9595
$shareTokens = array_map(function ($share) {
9696
return $share->getToken();
@@ -103,7 +103,7 @@ public function testFindAllByOwnerIsSuccessfulAndDoesNotContainOtherShares() {
103103

104104
public function testFindOrCreateByOwnerAndCategoryIsSuccessful() {
105105
/* @var FavoriteShare */
106-
$share = $this->favoriteShareMapper->findOrCreateByOwnerAndCategory("testUser", "testCategory");
106+
$share = $this->mapper->findOrCreateByOwnerAndCategory("testUser", "testCategory");
107107

108108
$this->assertIsString($share->getToken());
109109
$this->assertEquals("testUser", $share->getOwner());
@@ -112,13 +112,13 @@ public function testFindOrCreateByOwnerAndCategoryIsSuccessful() {
112112

113113
public function testRemoveByOwnerAndCategoryIsSuccessful() {
114114
/* @var FavoriteShare */
115-
$share = $this->favoriteShareMapper->create("testUser", "testCategory");
115+
$share = $this->mapper->create("testUser", "testCategory");
116116

117-
$this->favoriteShareMapper->removeByOwnerAndCategory($share->getOwner(), $share->getCategory());
117+
$this->mapper->removeByOwnerAndCategory($share->getOwner(), $share->getCategory());
118118

119119
$this->expectException(DoesNotExistException::class);
120120

121-
$this->favoriteShareMapper->findByOwnerAndCategory($share->getOwner(), $share->getCategory());
121+
$this->mapper->findByOwnerAndCategory($share->getOwner(), $share->getCategory());
122122
}
123123

124124
}

0 commit comments

Comments
 (0)