Commit cf45ec63 authored by Jens Segers's avatar Jens Segers

Make tests compatible with latest phpunit version

parent 7592967c
...@@ -7,3 +7,4 @@ composer.lock ...@@ -7,3 +7,4 @@ composer.lock
*.sublime-workspace *.sublime-workspace
*.project *.project
.idea/ .idea/
.phpunit.result.cache
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false">
verbose="true"
>
<testsuites> <testsuites>
<testsuite name="all"> <testsuite name="all">
<directory>tests/</directory> <directory>tests/</directory>
......
...@@ -47,7 +47,7 @@ class ConnectionTest extends TestCase ...@@ -47,7 +47,7 @@ class ConnectionTest extends TestCase
// public function testDynamic() // public function testDynamic()
// { // {
// $dbs = DB::connection('mongodb')->listCollections(); // $dbs = DB::connection('mongodb')->listCollections();
// $this->assertInternalType('array', $dbs); // $this->assertIsArray($dbs);
// } // }
// public function testMultipleConnections() // public function testMultipleConnections()
......
...@@ -37,7 +37,7 @@ class EmbeddedRelationsTest extends TestCase ...@@ -37,7 +37,7 @@ class EmbeddedRelationsTest extends TestCase
$this->assertInstanceOf('DateTime', $address->created_at); $this->assertInstanceOf('DateTime', $address->created_at);
$this->assertInstanceOf('DateTime', $address->updated_at); $this->assertInstanceOf('DateTime', $address->updated_at);
$this->assertNotNull($address->_id); $this->assertNotNull($address->_id);
$this->assertInternalType('string', $address->_id); $this->assertIsString($address->_id);
$raw = $address->getAttributes(); $raw = $address->getAttributes();
$this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']); $this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']);
...@@ -177,7 +177,7 @@ class EmbeddedRelationsTest extends TestCase ...@@ -177,7 +177,7 @@ class EmbeddedRelationsTest extends TestCase
$user = User::create([]); $user = User::create([]);
$address = $user->addresses()->create(['city' => 'Bruxelles']); $address = $user->addresses()->create(['city' => 'Bruxelles']);
$this->assertInstanceOf('Address', $address); $this->assertInstanceOf('Address', $address);
$this->assertInternalType('string', $address->_id); $this->assertIsString($address->_id);
$this->assertEquals(['Bruxelles'], $user->addresses->pluck('city')->all()); $this->assertEquals(['Bruxelles'], $user->addresses->pluck('city')->all());
$raw = $address->getAttributes(); $raw = $address->getAttributes();
...@@ -188,7 +188,7 @@ class EmbeddedRelationsTest extends TestCase ...@@ -188,7 +188,7 @@ class EmbeddedRelationsTest extends TestCase
$user = User::create([]); $user = User::create([]);
$address = $user->addresses()->create(['_id' => '', 'city' => 'Bruxelles']); $address = $user->addresses()->create(['_id' => '', 'city' => 'Bruxelles']);
$this->assertInternalType('string', $address->_id); $this->assertIsString($address->_id);
$raw = $address->getAttributes(); $raw = $address->getAttributes();
$this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']); $this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']);
...@@ -388,14 +388,14 @@ class EmbeddedRelationsTest extends TestCase ...@@ -388,14 +388,14 @@ class EmbeddedRelationsTest extends TestCase
$relations = $user->getRelations(); $relations = $user->getRelations();
$this->assertArrayNotHasKey('addresses', $relations); $this->assertArrayNotHasKey('addresses', $relations);
$this->assertArrayHasKey('addresses', $user->toArray()); $this->assertArrayHasKey('addresses', $user->toArray());
$this->assertInternalType('array', $user->toArray()['addresses']); $this->assertIsArray($user->toArray()['addresses']);
$user = User::with('addresses')->get()->first(); $user = User::with('addresses')->get()->first();
$relations = $user->getRelations(); $relations = $user->getRelations();
$this->assertArrayHasKey('addresses', $relations); $this->assertArrayHasKey('addresses', $relations);
$this->assertEquals(2, $relations['addresses']->count()); $this->assertEquals(2, $relations['addresses']->count());
$this->assertArrayHasKey('addresses', $user->toArray()); $this->assertArrayHasKey('addresses', $user->toArray());
$this->assertInternalType('array', $user->toArray()['addresses']); $this->assertIsArray($user->toArray()['addresses']);
} }
public function testEmbedsManyDeleteAll() public function testEmbedsManyDeleteAll()
...@@ -467,7 +467,7 @@ class EmbeddedRelationsTest extends TestCase ...@@ -467,7 +467,7 @@ class EmbeddedRelationsTest extends TestCase
$this->assertInstanceOf('DateTime', $father->created_at); $this->assertInstanceOf('DateTime', $father->created_at);
$this->assertInstanceOf('DateTime', $father->updated_at); $this->assertInstanceOf('DateTime', $father->updated_at);
$this->assertNotNull($father->_id); $this->assertNotNull($father->_id);
$this->assertInternalType('string', $father->_id); $this->assertIsString($father->_id);
$raw = $father->getAttributes(); $raw = $father->getAttributes();
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $raw['_id']); $this->assertInstanceOf('MongoDB\BSON\ObjectID', $raw['_id']);
...@@ -543,7 +543,7 @@ class EmbeddedRelationsTest extends TestCase ...@@ -543,7 +543,7 @@ class EmbeddedRelationsTest extends TestCase
$array = $user->toArray(); $array = $user->toArray();
$this->assertArrayHasKey('addresses', $array); $this->assertArrayHasKey('addresses', $array);
$this->assertInternalType('array', $array['addresses']); $this->assertIsArray($array['addresses']);
} }
public function testEmbeddedSave() public function testEmbeddedSave()
......
...@@ -28,7 +28,7 @@ class HybridRelationsTest extends TestCase ...@@ -28,7 +28,7 @@ class HybridRelationsTest extends TestCase
// Mysql User // Mysql User
$user->name = "John Doe"; $user->name = "John Doe";
$user->save(); $user->save();
$this->assertInternalType('int', $user->id); $this->assertIsInt($user->id);
// SQL has many // SQL has many
$book = new Book(['title' => 'Game of Thrones']); $book = new Book(['title' => 'Game of Thrones']);
...@@ -94,8 +94,8 @@ class HybridRelationsTest extends TestCase ...@@ -94,8 +94,8 @@ class HybridRelationsTest extends TestCase
$otherUser->id = 3; $otherUser->id = 3;
$otherUser->save(); $otherUser->save();
// Make sure they are created // Make sure they are created
$this->assertInternalType('int', $user->id); $this->assertIsInt($user->id);
$this->assertInternalType('int', $otherUser->id); $this->assertIsInt($otherUser->id);
// Clear to start // Clear to start
$user->books()->truncate(); $user->books()->truncate();
$otherUser->books()->truncate(); $otherUser->books()->truncate();
...@@ -148,8 +148,8 @@ class HybridRelationsTest extends TestCase ...@@ -148,8 +148,8 @@ class HybridRelationsTest extends TestCase
$otherUser->id = 3; $otherUser->id = 3;
$otherUser->save(); $otherUser->save();
// Make sure they are created // Make sure they are created
$this->assertInternalType('int', $user->id); $this->assertIsInt($user->id);
$this->assertInternalType('int', $otherUser->id); $this->assertIsInt($otherUser->id);
// Clear to start // Clear to start
Book::truncate(); Book::truncate();
MysqlBook::truncate(); MysqlBook::truncate();
......
...@@ -41,7 +41,7 @@ class ModelTest extends TestCase ...@@ -41,7 +41,7 @@ class ModelTest extends TestCase
$this->assertEquals(1, User::count()); $this->assertEquals(1, User::count());
$this->assertTrue(isset($user->_id)); $this->assertTrue(isset($user->_id));
$this->assertInternalType('string', $user->_id); $this->assertIsString($user->_id);
$this->assertNotEquals('', (string) $user->_id); $this->assertNotEquals('', (string) $user->_id);
$this->assertNotEquals(0, strlen((string) $user->_id)); $this->assertNotEquals(0, strlen((string) $user->_id));
$this->assertInstanceOf(Carbon::class, $user->created_at); $this->assertInstanceOf(Carbon::class, $user->created_at);
...@@ -112,7 +112,7 @@ class ModelTest extends TestCase ...@@ -112,7 +112,7 @@ class ModelTest extends TestCase
$this->assertEquals('customId', $user->_id); $this->assertEquals('customId', $user->_id);
$raw = $user->getAttributes(); $raw = $user->getAttributes();
$this->assertInternalType('string', $raw['_id']); $this->assertIsString($raw['_id']);
} }
public function testManualIntId(): void public function testManualIntId(): void
...@@ -128,7 +128,7 @@ class ModelTest extends TestCase ...@@ -128,7 +128,7 @@ class ModelTest extends TestCase
$this->assertEquals(1, $user->_id); $this->assertEquals(1, $user->_id);
$raw = $user->getAttributes(); $raw = $user->getAttributes();
$this->assertInternalType('integer', $raw['_id']); $this->assertIsInt($raw['_id']);
} }
public function testDelete(): void public function testDelete(): void
...@@ -349,9 +349,9 @@ class ModelTest extends TestCase ...@@ -349,9 +349,9 @@ class ModelTest extends TestCase
$keys = array_keys($array); $keys = array_keys($array);
sort($keys); sort($keys);
$this->assertEquals(['_id', 'created_at', 'name', 'type', 'updated_at'], $keys); $this->assertEquals(['_id', 'created_at', 'name', 'type', 'updated_at'], $keys);
$this->assertInternalType('string', $array['created_at']); $this->assertIsString($array['created_at']);
$this->assertInternalType('string', $array['updated_at']); $this->assertIsString($array['updated_at']);
$this->assertInternalType('string', $array['_id']); $this->assertIsString($array['_id']);
} }
public function testUnset(): void public function testUnset(): void
......
...@@ -87,7 +87,7 @@ class QueryBuilderTest extends TestCase ...@@ -87,7 +87,7 @@ class QueryBuilderTest extends TestCase
$user = $users[0]; $user = $users[0];
$this->assertEquals('John Doe', $user['name']); $this->assertEquals('John Doe', $user['name']);
$this->assertInternalType('array', $user['tags']); $this->assertIsArray($user['tags']);
} }
public function testInsertGetId() public function testInsertGetId()
...@@ -111,7 +111,7 @@ class QueryBuilderTest extends TestCase ...@@ -111,7 +111,7 @@ class QueryBuilderTest extends TestCase
$users = DB::collection('users')->get(); $users = DB::collection('users')->get();
$this->assertCount(2, $users); $this->assertCount(2, $users);
$this->assertInternalType('array', $users[0]['tags']); $this->assertIsArray($users[0]['tags']);
} }
public function testFind() public function testFind()
...@@ -247,7 +247,7 @@ class QueryBuilderTest extends TestCase ...@@ -247,7 +247,7 @@ class QueryBuilderTest extends TestCase
DB::collection('users')->where('_id', $id)->push('tags', 'tag1'); DB::collection('users')->where('_id', $id)->push('tags', 'tag1');
$user = DB::collection('users')->find($id); $user = DB::collection('users')->find($id);
$this->assertInternalType('array', $user['tags']); $this->assertIsArray($user['tags']);
$this->assertCount(1, $user['tags']); $this->assertCount(1, $user['tags']);
$this->assertEquals('tag1', $user['tags'][0]); $this->assertEquals('tag1', $user['tags'][0]);
...@@ -269,7 +269,7 @@ class QueryBuilderTest extends TestCase ...@@ -269,7 +269,7 @@ class QueryBuilderTest extends TestCase
$message = ['from' => 'Jane', 'body' => 'Hi John']; $message = ['from' => 'Jane', 'body' => 'Hi John'];
DB::collection('users')->where('_id', $id)->push('messages', $message); DB::collection('users')->where('_id', $id)->push('messages', $message);
$user = DB::collection('users')->find($id); $user = DB::collection('users')->find($id);
$this->assertInternalType('array', $user['messages']); $this->assertIsArray($user['messages']);
$this->assertCount(1, $user['messages']); $this->assertCount(1, $user['messages']);
$this->assertEquals($message, $user['messages'][0]); $this->assertEquals($message, $user['messages'][0]);
...@@ -298,14 +298,14 @@ class QueryBuilderTest extends TestCase ...@@ -298,14 +298,14 @@ class QueryBuilderTest extends TestCase
DB::collection('users')->where('_id', $id)->pull('tags', 'tag3'); DB::collection('users')->where('_id', $id)->pull('tags', 'tag3');
$user = DB::collection('users')->find($id); $user = DB::collection('users')->find($id);
$this->assertInternalType('array', $user['tags']); $this->assertIsArray($user['tags']);
$this->assertCount(3, $user['tags']); $this->assertCount(3, $user['tags']);
$this->assertEquals('tag4', $user['tags'][2]); $this->assertEquals('tag4', $user['tags'][2]);
DB::collection('users')->where('_id', $id)->pull('messages', $message1); DB::collection('users')->where('_id', $id)->pull('messages', $message1);
$user = DB::collection('users')->find($id); $user = DB::collection('users')->find($id);
$this->assertInternalType('array', $user['messages']); $this->assertIsArray($user['messages']);
$this->assertCount(1, $user['messages']); $this->assertCount(1, $user['messages']);
// Raw // Raw
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment