Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
cf45ec63
Commit
cf45ec63
authored
Sep 08, 2019
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
Make tests compatible with latest phpunit version
parent
7592967c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
28 deletions
+27
-28
.gitignore
.gitignore
+1
-0
phpunit.xml.dist
phpunit.xml.dist
+1
-3
ConnectionTest.php
tests/ConnectionTest.php
+1
-1
EmbeddedRelationsTest.php
tests/EmbeddedRelationsTest.php
+7
-7
HybridRelationsTest.php
tests/HybridRelationsTest.php
+5
-5
ModelTest.php
tests/ModelTest.php
+6
-6
QueryBuilderTest.php
tests/QueryBuilderTest.php
+6
-6
No files found.
.gitignore
View file @
cf45ec63
...
...
@@ -7,3 +7,4 @@ composer.lock
*.sublime-workspace
*.project
.idea/
.phpunit.result.cache
phpunit.xml.dist
View file @
cf45ec63
...
...
@@ -7,9 +7,7 @@
convertNoticesToExceptions=
"true"
convertWarningsToExceptions=
"true"
processIsolation=
"false"
stopOnFailure=
"false"
verbose=
"true"
>
stopOnFailure=
"false"
>
<testsuites>
<testsuite
name=
"all"
>
<directory>
tests/
</directory>
...
...
tests/ConnectionTest.php
View file @
cf45ec63
...
...
@@ -47,7 +47,7 @@ class ConnectionTest extends TestCase
// public function testDynamic()
// {
// $dbs = DB::connection('mongodb')->listCollections();
// $this->assertI
nternalType('array',
$dbs);
// $this->assertI
sArray(
$dbs);
// }
// public function testMultipleConnections()
...
...
tests/EmbeddedRelationsTest.php
View file @
cf45ec63
...
...
@@ -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
->
assertI
nternalType
(
'string'
,
$address
->
_id
);
$this
->
assertI
sString
(
$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
->
assertI
nternalType
(
'string'
,
$address
->
_id
);
$this
->
assertI
sString
(
$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
->
assertI
nternalType
(
'string'
,
$address
->
_id
);
$this
->
assertI
sString
(
$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
->
assertI
nternalType
(
'array'
,
$user
->
toArray
()[
'addresses'
]);
$this
->
assertI
sArray
(
$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
->
assertI
nternalType
(
'array'
,
$user
->
toArray
()[
'addresses'
]);
$this
->
assertI
sArray
(
$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
->
assertI
nternalType
(
'string'
,
$father
->
_id
);
$this
->
assertI
sString
(
$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
->
assertI
nternalType
(
'array'
,
$array
[
'addresses'
]);
$this
->
assertI
sArray
(
$array
[
'addresses'
]);
}
public
function
testEmbeddedSave
()
...
...
tests/HybridRelationsTest.php
View file @
cf45ec63
...
...
@@ -28,7 +28,7 @@ class HybridRelationsTest extends TestCase
// Mysql User
$user
->
name
=
"John Doe"
;
$user
->
save
();
$this
->
assertI
nternalType
(
'int'
,
$user
->
id
);
$this
->
assertI
sInt
(
$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
->
assertI
nternalType
(
'int'
,
$user
->
id
);
$this
->
assertI
nternalType
(
'int'
,
$otherUser
->
id
);
$this
->
assertI
sInt
(
$user
->
id
);
$this
->
assertI
sInt
(
$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
->
assertI
nternalType
(
'int'
,
$user
->
id
);
$this
->
assertI
nternalType
(
'int'
,
$otherUser
->
id
);
$this
->
assertI
sInt
(
$user
->
id
);
$this
->
assertI
sInt
(
$otherUser
->
id
);
// Clear to start
Book
::
truncate
();
MysqlBook
::
truncate
();
...
...
tests/ModelTest.php
View file @
cf45ec63
...
...
@@ -41,7 +41,7 @@ class ModelTest extends TestCase
$this
->
assertEquals
(
1
,
User
::
count
());
$this
->
assertTrue
(
isset
(
$user
->
_id
));
$this
->
assertI
nternalType
(
'string'
,
$user
->
_id
);
$this
->
assertI
sString
(
$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
->
assertI
nternalType
(
'string'
,
$raw
[
'_id'
]);
$this
->
assertI
sString
(
$raw
[
'_id'
]);
}
public
function
testManualIntId
()
:
void
...
...
@@ -128,7 +128,7 @@ class ModelTest extends TestCase
$this
->
assertEquals
(
1
,
$user
->
_id
);
$raw
=
$user
->
getAttributes
();
$this
->
assertI
nternalType
(
'integer'
,
$raw
[
'_id'
]);
$this
->
assertI
sInt
(
$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
->
assertI
nternalType
(
'string'
,
$array
[
'created_at'
]);
$this
->
assertI
nternalType
(
'string'
,
$array
[
'updated_at'
]);
$this
->
assertI
nternalType
(
'string'
,
$array
[
'_id'
]);
$this
->
assertI
sString
(
$array
[
'created_at'
]);
$this
->
assertI
sString
(
$array
[
'updated_at'
]);
$this
->
assertI
sString
(
$array
[
'_id'
]);
}
public
function
testUnset
()
:
void
...
...
tests/QueryBuilderTest.php
View file @
cf45ec63
...
...
@@ -87,7 +87,7 @@ class QueryBuilderTest extends TestCase
$user
=
$users
[
0
];
$this
->
assertEquals
(
'John Doe'
,
$user
[
'name'
]);
$this
->
assertI
nternalType
(
'array'
,
$user
[
'tags'
]);
$this
->
assertI
sArray
(
$user
[
'tags'
]);
}
public
function
testInsertGetId
()
...
...
@@ -111,7 +111,7 @@ class QueryBuilderTest extends TestCase
$users
=
DB
::
collection
(
'users'
)
->
get
();
$this
->
assertCount
(
2
,
$users
);
$this
->
assertI
nternalType
(
'array'
,
$users
[
0
][
'tags'
]);
$this
->
assertI
sArray
(
$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
->
assertI
nternalType
(
'array'
,
$user
[
'tags'
]);
$this
->
assertI
sArray
(
$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
->
assertI
nternalType
(
'array'
,
$user
[
'messages'
]);
$this
->
assertI
sArray
(
$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
->
assertI
nternalType
(
'array'
,
$user
[
'tags'
]);
$this
->
assertI
sArray
(
$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
->
assertI
nternalType
(
'array'
,
$user
[
'messages'
]);
$this
->
assertI
sArray
(
$user
[
'messages'
]);
$this
->
assertCount
(
1
,
$user
[
'messages'
]);
// Raw
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment