Skip to content

Commit cf45ec6

Browse files
committed
♻️ Make tests compatible with latest phpunit version
1 parent 7592967 commit cf45ec6

File tree

7 files changed

+27
-28
lines changed

7 files changed

+27
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ composer.lock
77
*.sublime-workspace
88
*.project
99
.idea/
10+
.phpunit.result.cache

phpunit.xml.dist

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
verbose="true"
12-
>
10+
stopOnFailure="false">
1311
<testsuites>
1412
<testsuite name="all">
1513
<directory>tests/</directory>

tests/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testCollection()
4747
// public function testDynamic()
4848
// {
4949
// $dbs = DB::connection('mongodb')->listCollections();
50-
// $this->assertInternalType('array', $dbs);
50+
// $this->assertIsArray($dbs);
5151
// }
5252

5353
// public function testMultipleConnections()

tests/EmbeddedRelationsTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testEmbedsManySave()
3737
$this->assertInstanceOf('DateTime', $address->created_at);
3838
$this->assertInstanceOf('DateTime', $address->updated_at);
3939
$this->assertNotNull($address->_id);
40-
$this->assertInternalType('string', $address->_id);
40+
$this->assertIsString($address->_id);
4141

4242
$raw = $address->getAttributes();
4343
$this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']);
@@ -177,7 +177,7 @@ public function testEmbedsManyCreate()
177177
$user = User::create([]);
178178
$address = $user->addresses()->create(['city' => 'Bruxelles']);
179179
$this->assertInstanceOf('Address', $address);
180-
$this->assertInternalType('string', $address->_id);
180+
$this->assertIsString($address->_id);
181181
$this->assertEquals(['Bruxelles'], $user->addresses->pluck('city')->all());
182182

183183
$raw = $address->getAttributes();
@@ -188,7 +188,7 @@ public function testEmbedsManyCreate()
188188

189189
$user = User::create([]);
190190
$address = $user->addresses()->create(['_id' => '', 'city' => 'Bruxelles']);
191-
$this->assertInternalType('string', $address->_id);
191+
$this->assertIsString($address->_id);
192192

193193
$raw = $address->getAttributes();
194194
$this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']);
@@ -388,14 +388,14 @@ public function testEmbedsManyEagerLoading()
388388
$relations = $user->getRelations();
389389
$this->assertArrayNotHasKey('addresses', $relations);
390390
$this->assertArrayHasKey('addresses', $user->toArray());
391-
$this->assertInternalType('array', $user->toArray()['addresses']);
391+
$this->assertIsArray($user->toArray()['addresses']);
392392

393393
$user = User::with('addresses')->get()->first();
394394
$relations = $user->getRelations();
395395
$this->assertArrayHasKey('addresses', $relations);
396396
$this->assertEquals(2, $relations['addresses']->count());
397397
$this->assertArrayHasKey('addresses', $user->toArray());
398-
$this->assertInternalType('array', $user->toArray()['addresses']);
398+
$this->assertIsArray($user->toArray()['addresses']);
399399
}
400400

401401
public function testEmbedsManyDeleteAll()
@@ -467,7 +467,7 @@ public function testEmbedsOne()
467467
$this->assertInstanceOf('DateTime', $father->created_at);
468468
$this->assertInstanceOf('DateTime', $father->updated_at);
469469
$this->assertNotNull($father->_id);
470-
$this->assertInternalType('string', $father->_id);
470+
$this->assertIsString($father->_id);
471471

472472
$raw = $father->getAttributes();
473473
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $raw['_id']);
@@ -543,7 +543,7 @@ public function testEmbedsManyToArray()
543543

544544
$array = $user->toArray();
545545
$this->assertArrayHasKey('addresses', $array);
546-
$this->assertInternalType('array', $array['addresses']);
546+
$this->assertIsArray($array['addresses']);
547547
}
548548

549549
public function testEmbeddedSave()

tests/HybridRelationsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testMysqlRelations()
2828
// Mysql User
2929
$user->name = "John Doe";
3030
$user->save();
31-
$this->assertInternalType('int', $user->id);
31+
$this->assertIsInt($user->id);
3232

3333
// SQL has many
3434
$book = new Book(['title' => 'Game of Thrones']);
@@ -94,8 +94,8 @@ public function testHybridWhereHas()
9494
$otherUser->id = 3;
9595
$otherUser->save();
9696
// Make sure they are created
97-
$this->assertInternalType('int', $user->id);
98-
$this->assertInternalType('int', $otherUser->id);
97+
$this->assertIsInt($user->id);
98+
$this->assertIsInt($otherUser->id);
9999
// Clear to start
100100
$user->books()->truncate();
101101
$otherUser->books()->truncate();
@@ -148,8 +148,8 @@ public function testHybridWith()
148148
$otherUser->id = 3;
149149
$otherUser->save();
150150
// Make sure they are created
151-
$this->assertInternalType('int', $user->id);
152-
$this->assertInternalType('int', $otherUser->id);
151+
$this->assertIsInt($user->id);
152+
$this->assertIsInt($otherUser->id);
153153
// Clear to start
154154
Book::truncate();
155155
MysqlBook::truncate();

tests/ModelTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testInsert(): void
4141
$this->assertEquals(1, User::count());
4242

4343
$this->assertTrue(isset($user->_id));
44-
$this->assertInternalType('string', $user->_id);
44+
$this->assertIsString($user->_id);
4545
$this->assertNotEquals('', (string) $user->_id);
4646
$this->assertNotEquals(0, strlen((string) $user->_id));
4747
$this->assertInstanceOf(Carbon::class, $user->created_at);
@@ -112,7 +112,7 @@ public function testManualStringId(): void
112112
$this->assertEquals('customId', $user->_id);
113113

114114
$raw = $user->getAttributes();
115-
$this->assertInternalType('string', $raw['_id']);
115+
$this->assertIsString($raw['_id']);
116116
}
117117

118118
public function testManualIntId(): void
@@ -128,7 +128,7 @@ public function testManualIntId(): void
128128
$this->assertEquals(1, $user->_id);
129129

130130
$raw = $user->getAttributes();
131-
$this->assertInternalType('integer', $raw['_id']);
131+
$this->assertIsInt($raw['_id']);
132132
}
133133

134134
public function testDelete(): void
@@ -349,9 +349,9 @@ public function testToArray(): void
349349
$keys = array_keys($array);
350350
sort($keys);
351351
$this->assertEquals(['_id', 'created_at', 'name', 'type', 'updated_at'], $keys);
352-
$this->assertInternalType('string', $array['created_at']);
353-
$this->assertInternalType('string', $array['updated_at']);
354-
$this->assertInternalType('string', $array['_id']);
352+
$this->assertIsString($array['created_at']);
353+
$this->assertIsString($array['updated_at']);
354+
$this->assertIsString($array['_id']);
355355
}
356356

357357
public function testUnset(): void

tests/QueryBuilderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testInsert()
8787

8888
$user = $users[0];
8989
$this->assertEquals('John Doe', $user['name']);
90-
$this->assertInternalType('array', $user['tags']);
90+
$this->assertIsArray($user['tags']);
9191
}
9292

9393
public function testInsertGetId()
@@ -111,7 +111,7 @@ public function testBatchInsert()
111111

112112
$users = DB::collection('users')->get();
113113
$this->assertCount(2, $users);
114-
$this->assertInternalType('array', $users[0]['tags']);
114+
$this->assertIsArray($users[0]['tags']);
115115
}
116116

117117
public function testFind()
@@ -247,7 +247,7 @@ public function testPush()
247247
DB::collection('users')->where('_id', $id)->push('tags', 'tag1');
248248

249249
$user = DB::collection('users')->find($id);
250-
$this->assertInternalType('array', $user['tags']);
250+
$this->assertIsArray($user['tags']);
251251
$this->assertCount(1, $user['tags']);
252252
$this->assertEquals('tag1', $user['tags'][0]);
253253

@@ -269,7 +269,7 @@ public function testPush()
269269
$message = ['from' => 'Jane', 'body' => 'Hi John'];
270270
DB::collection('users')->where('_id', $id)->push('messages', $message);
271271
$user = DB::collection('users')->find($id);
272-
$this->assertInternalType('array', $user['messages']);
272+
$this->assertIsArray($user['messages']);
273273
$this->assertCount(1, $user['messages']);
274274
$this->assertEquals($message, $user['messages'][0]);
275275

@@ -298,14 +298,14 @@ public function testPull()
298298
DB::collection('users')->where('_id', $id)->pull('tags', 'tag3');
299299

300300
$user = DB::collection('users')->find($id);
301-
$this->assertInternalType('array', $user['tags']);
301+
$this->assertIsArray($user['tags']);
302302
$this->assertCount(3, $user['tags']);
303303
$this->assertEquals('tag4', $user['tags'][2]);
304304

305305
DB::collection('users')->where('_id', $id)->pull('messages', $message1);
306306

307307
$user = DB::collection('users')->find($id);
308-
$this->assertInternalType('array', $user['messages']);
308+
$this->assertIsArray($user['messages']);
309309
$this->assertCount(1, $user['messages']);
310310

311311
// Raw

0 commit comments

Comments
 (0)