diff --git a/.gitignore b/.gitignore index 1fe4e30f6..c7e087c4c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ composer.lock *.sublime-workspace *.project .idea/ +.phpunit.result.cache diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e2d82d39d..0a10014c2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,9 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" - verbose="true" -> + stopOnFailure="false"> tests/ diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 777169a06..b636ef2fd 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -47,7 +47,7 @@ public function testCollection() // public function testDynamic() // { // $dbs = DB::connection('mongodb')->listCollections(); - // $this->assertInternalType('array', $dbs); + // $this->assertIsArray($dbs); // } // public function testMultipleConnections() diff --git a/tests/EmbeddedRelationsTest.php b/tests/EmbeddedRelationsTest.php index 93af2180f..81e9e1bd8 100644 --- a/tests/EmbeddedRelationsTest.php +++ b/tests/EmbeddedRelationsTest.php @@ -37,7 +37,7 @@ public function testEmbedsManySave() $this->assertInstanceOf('DateTime', $address->created_at); $this->assertInstanceOf('DateTime', $address->updated_at); $this->assertNotNull($address->_id); - $this->assertInternalType('string', $address->_id); + $this->assertIsString($address->_id); $raw = $address->getAttributes(); $this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']); @@ -177,7 +177,7 @@ public function testEmbedsManyCreate() $user = User::create([]); $address = $user->addresses()->create(['city' => 'Bruxelles']); $this->assertInstanceOf('Address', $address); - $this->assertInternalType('string', $address->_id); + $this->assertIsString($address->_id); $this->assertEquals(['Bruxelles'], $user->addresses->pluck('city')->all()); $raw = $address->getAttributes(); @@ -188,7 +188,7 @@ public function testEmbedsManyCreate() $user = User::create([]); $address = $user->addresses()->create(['_id' => '', 'city' => 'Bruxelles']); - $this->assertInternalType('string', $address->_id); + $this->assertIsString($address->_id); $raw = $address->getAttributes(); $this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']); @@ -388,14 +388,14 @@ public function testEmbedsManyEagerLoading() $relations = $user->getRelations(); $this->assertArrayNotHasKey('addresses', $relations); $this->assertArrayHasKey('addresses', $user->toArray()); - $this->assertInternalType('array', $user->toArray()['addresses']); + $this->assertIsArray($user->toArray()['addresses']); $user = User::with('addresses')->get()->first(); $relations = $user->getRelations(); $this->assertArrayHasKey('addresses', $relations); $this->assertEquals(2, $relations['addresses']->count()); $this->assertArrayHasKey('addresses', $user->toArray()); - $this->assertInternalType('array', $user->toArray()['addresses']); + $this->assertIsArray($user->toArray()['addresses']); } public function testEmbedsManyDeleteAll() @@ -467,7 +467,7 @@ public function testEmbedsOne() $this->assertInstanceOf('DateTime', $father->created_at); $this->assertInstanceOf('DateTime', $father->updated_at); $this->assertNotNull($father->_id); - $this->assertInternalType('string', $father->_id); + $this->assertIsString($father->_id); $raw = $father->getAttributes(); $this->assertInstanceOf('MongoDB\BSON\ObjectID', $raw['_id']); @@ -543,7 +543,7 @@ public function testEmbedsManyToArray() $array = $user->toArray(); $this->assertArrayHasKey('addresses', $array); - $this->assertInternalType('array', $array['addresses']); + $this->assertIsArray($array['addresses']); } public function testEmbeddedSave() diff --git a/tests/HybridRelationsTest.php b/tests/HybridRelationsTest.php index 832eb6f86..303762ca2 100644 --- a/tests/HybridRelationsTest.php +++ b/tests/HybridRelationsTest.php @@ -28,7 +28,7 @@ public function testMysqlRelations() // Mysql User $user->name = "John Doe"; $user->save(); - $this->assertInternalType('int', $user->id); + $this->assertIsInt($user->id); // SQL has many $book = new Book(['title' => 'Game of Thrones']); @@ -94,8 +94,8 @@ public function testHybridWhereHas() $otherUser->id = 3; $otherUser->save(); // Make sure they are created - $this->assertInternalType('int', $user->id); - $this->assertInternalType('int', $otherUser->id); + $this->assertIsInt($user->id); + $this->assertIsInt($otherUser->id); // Clear to start $user->books()->truncate(); $otherUser->books()->truncate(); @@ -148,8 +148,8 @@ public function testHybridWith() $otherUser->id = 3; $otherUser->save(); // Make sure they are created - $this->assertInternalType('int', $user->id); - $this->assertInternalType('int', $otherUser->id); + $this->assertIsInt($user->id); + $this->assertIsInt($otherUser->id); // Clear to start Book::truncate(); MysqlBook::truncate(); diff --git a/tests/ModelTest.php b/tests/ModelTest.php index e68b00cb0..bbc747942 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -41,7 +41,7 @@ public function testInsert(): void $this->assertEquals(1, User::count()); $this->assertTrue(isset($user->_id)); - $this->assertInternalType('string', $user->_id); + $this->assertIsString($user->_id); $this->assertNotEquals('', (string) $user->_id); $this->assertNotEquals(0, strlen((string) $user->_id)); $this->assertInstanceOf(Carbon::class, $user->created_at); @@ -112,7 +112,7 @@ public function testManualStringId(): void $this->assertEquals('customId', $user->_id); $raw = $user->getAttributes(); - $this->assertInternalType('string', $raw['_id']); + $this->assertIsString($raw['_id']); } public function testManualIntId(): void @@ -128,7 +128,7 @@ public function testManualIntId(): void $this->assertEquals(1, $user->_id); $raw = $user->getAttributes(); - $this->assertInternalType('integer', $raw['_id']); + $this->assertIsInt($raw['_id']); } public function testDelete(): void @@ -349,9 +349,9 @@ public function testToArray(): void $keys = array_keys($array); sort($keys); $this->assertEquals(['_id', 'created_at', 'name', 'type', 'updated_at'], $keys); - $this->assertInternalType('string', $array['created_at']); - $this->assertInternalType('string', $array['updated_at']); - $this->assertInternalType('string', $array['_id']); + $this->assertIsString($array['created_at']); + $this->assertIsString($array['updated_at']); + $this->assertIsString($array['_id']); } public function testUnset(): void diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index 4b1321684..1a7a8ffb9 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -87,7 +87,7 @@ public function testInsert() $user = $users[0]; $this->assertEquals('John Doe', $user['name']); - $this->assertInternalType('array', $user['tags']); + $this->assertIsArray($user['tags']); } public function testInsertGetId() @@ -111,7 +111,7 @@ public function testBatchInsert() $users = DB::collection('users')->get(); $this->assertCount(2, $users); - $this->assertInternalType('array', $users[0]['tags']); + $this->assertIsArray($users[0]['tags']); } public function testFind() @@ -247,7 +247,7 @@ public function testPush() DB::collection('users')->where('_id', $id)->push('tags', 'tag1'); $user = DB::collection('users')->find($id); - $this->assertInternalType('array', $user['tags']); + $this->assertIsArray($user['tags']); $this->assertCount(1, $user['tags']); $this->assertEquals('tag1', $user['tags'][0]); @@ -269,7 +269,7 @@ public function testPush() $message = ['from' => 'Jane', 'body' => 'Hi John']; DB::collection('users')->where('_id', $id)->push('messages', $message); $user = DB::collection('users')->find($id); - $this->assertInternalType('array', $user['messages']); + $this->assertIsArray($user['messages']); $this->assertCount(1, $user['messages']); $this->assertEquals($message, $user['messages'][0]); @@ -298,14 +298,14 @@ public function testPull() DB::collection('users')->where('_id', $id)->pull('tags', 'tag3'); $user = DB::collection('users')->find($id); - $this->assertInternalType('array', $user['tags']); + $this->assertIsArray($user['tags']); $this->assertCount(3, $user['tags']); $this->assertEquals('tag4', $user['tags'][2]); DB::collection('users')->where('_id', $id)->pull('messages', $message1); $user = DB::collection('users')->find($id); - $this->assertInternalType('array', $user['messages']); + $this->assertIsArray($user['messages']); $this->assertCount(1, $user['messages']); // Raw