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
7bd92dbc
Commit
7bd92dbc
authored
Mar 10, 2020
by
Ditty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove test and revert back old test
parent
31b0fdf0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
112 deletions
+6
-112
DatabaseEloquentTimestampsTest.php
tests/DatabaseEloquentTimestampsTest.php
+0
-107
ModelTest.php
tests/ModelTest.php
+6
-0
User.php
tests/models/User.php
+0
-5
No files found.
tests/DatabaseEloquentTimestampsTest.php
deleted
100644 → 0
View file @
31b0fdf0
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Support\Carbon
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
class
DatabaseEloquentTimestampsTest
extends
TestCase
{
/**
* Tear down the database schema.
*
* @return void
*/
protected
function
tearDown
()
:
void
{
$this
->
schema
()
->
drop
(
'users'
);
$this
->
schema
()
->
drop
(
'users_created_at'
);
$this
->
schema
()
->
drop
(
'users_updated_at'
);
}
/**
* Tests...
*/
public
function
testUserWithCreatedAtAndUpdatedAt
()
{
$now
=
Carbon
::
now
();
$user
=
UserWithCreatedAndUpdated
::
create
([
'email'
=>
'test@test.com'
,
]);
$this
->
assertEquals
(
$now
->
toDateTimeString
(),
$user
->
created_at
->
toDateTimeString
());
$this
->
assertEquals
(
$now
->
toDateTimeString
(),
$user
->
updated_at
->
toDateTimeString
());
}
public
function
testUserWithCreatedAt
()
{
$now
=
Carbon
::
now
();
$user
=
UserWithCreated
::
create
([
'email'
=>
'test@test.com'
,
]);
$this
->
assertEquals
(
$now
->
toDateTimeString
(),
$user
->
created_at
->
toDateTimeString
());
}
public
function
testUserWithUpdatedAt
()
{
$now
=
Carbon
::
now
();
$user
=
UserWithUpdated
::
create
([
'email'
=>
'test@test.com'
,
]);
$this
->
assertEquals
(
$now
->
toDateTimeString
(),
$user
->
updated_at
->
toDateTimeString
());
}
/**
* Get a database connection instance.
*
* @return \Illuminate\Database\ConnectionInterface
*/
protected
function
connection
()
{
return
Eloquent
::
getConnectionResolver
()
->
connection
();
}
/**
* Get a schema builder instance.
*
* @return \Illuminate\Database\Schema\Builder
*/
protected
function
schema
()
{
return
$this
->
connection
()
->
getSchemaBuilder
();
}
}
/**
* Eloquent Models...
*/
class
UserWithCreatedAndUpdated
extends
Eloquent
{
protected
$collection
=
'users'
;
protected
$guarded
=
[];
}
class
UserWithCreated
extends
Eloquent
{
public
const
UPDATED_AT
=
null
;
protected
$collection
=
'users_created_at'
;
protected
$guarded
=
[];
protected
$dateFormat
=
'U'
;
}
class
UserWithUpdated
extends
Eloquent
{
public
const
CREATED_AT
=
null
;
protected
$collection
=
'users_updated_at'
;
protected
$guarded
=
[];
protected
$dateFormat
=
'U'
;
}
tests/ModelTest.php
View file @
7bd92dbc
...
@@ -405,6 +405,12 @@ class ModelTest extends TestCase
...
@@ -405,6 +405,12 @@ class ModelTest extends TestCase
->
getTimestamp
(),
$item
->
created_at
->
getTimestamp
());
->
getTimestamp
(),
$item
->
created_at
->
getTimestamp
());
$this
->
assertLessThan
(
2
,
abs
(
time
()
-
$item
->
created_at
->
getTimestamp
()));
$this
->
assertLessThan
(
2
,
abs
(
time
()
-
$item
->
created_at
->
getTimestamp
()));
// test default date format for json output
/** @var Item $item */
$item
=
Item
::
create
([
'name'
=>
'sword'
]);
$json
=
$item
->
toArray
();
$this
->
assertEquals
(
$item
->
created_at
->
format
(
'Y-m-d\TH:i:s.u\Z'
),
$json
[
'created_at'
]);
/** @var User $user */
/** @var User $user */
$user
=
User
::
create
([
'name'
=>
'Jane Doe'
,
'birthday'
=>
time
()]);
$user
=
User
::
create
([
'name'
=>
'Jane Doe'
,
'birthday'
=>
time
()]);
$this
->
assertInstanceOf
(
Carbon
::
class
,
$user
->
birthday
);
$this
->
assertInstanceOf
(
Carbon
::
class
,
$user
->
birthday
);
...
...
tests/models/User.php
View file @
7bd92dbc
...
@@ -67,9 +67,4 @@ class User extends Eloquent implements AuthenticatableContract, CanResetPassword
...
@@ -67,9 +67,4 @@ class User extends Eloquent implements AuthenticatableContract, CanResetPassword
{
{
return
$this
->
morphMany
(
'Photo'
,
'imageable'
);
return
$this
->
morphMany
(
'Photo'
,
'imageable'
);
}
}
public
function
getDateFormat
()
{
return
'l jS \of F Y h:i:s A'
;
}
}
}
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