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
*.sublime-workspace
*.project
.idea/
.phpunit.result.cache
......@@ -7,9 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
stopOnFailure="false">
<testsuites>
<testsuite name="all">
<directory>tests/</directory>
......
......@@ -47,7 +47,7 @@ class ConnectionTest extends TestCase
// public function testDynamic()
// {
// $dbs = DB::connection('mongodb')->listCollections();
// $this->assertInternalType('array', $dbs);
// $this->assertIsArray($dbs);
// }
// public function testMultipleConnections()
......
......@@ -37,7 +37,7 @@ class EmbeddedRelationsTest extends TestCase
$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 @@ class EmbeddedRelationsTest extends TestCase
$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 @@ class EmbeddedRelationsTest extends TestCase
$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 @@ class EmbeddedRelationsTest extends TestCase
$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 @@ class EmbeddedRelationsTest extends TestCase
$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 @@ class EmbeddedRelationsTest extends TestCase
$array = $user->toArray();
$this->assertArrayHasKey('addresses', $array);
$this->assertInternalType('array', $array['addresses']);
$this->assertIsArray($array['addresses']);
}
public function testEmbeddedSave()
......
......@@ -28,7 +28,7 @@ class HybridRelationsTest extends TestCase
// 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 @@ class HybridRelationsTest extends TestCase
$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 @@ class HybridRelationsTest extends TestCase
$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();
......
......@@ -41,7 +41,7 @@ class ModelTest extends TestCase
$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 @@ class ModelTest extends TestCase
$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 @@ class ModelTest extends TestCase
$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 @@ class ModelTest extends TestCase
$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
......
......@@ -87,7 +87,7 @@ class QueryBuilderTest extends TestCase
$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 @@ class QueryBuilderTest extends TestCase
$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 @@ class QueryBuilderTest extends TestCase
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 @@ class QueryBuilderTest extends TestCase
$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 @@ class QueryBuilderTest extends TestCase
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
......
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