Commit bd26b77b authored by Jens Segers's avatar Jens Segers

Running tests on Laravel 5.1

parent 9737b9bb
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"illuminate/events": "^5.0" "illuminate/events": "^5.0"
}, },
"require-dev": { "require-dev": {
"orchestra/testbench": "3.0.*", "orchestra/testbench": "~3.1.0",
"mockery/mockery": "*", "mockery/mockery": "*",
"satooshi/php-coveralls": "*" "satooshi/php-coveralls": "*"
}, },
......
...@@ -196,17 +196,7 @@ abstract class Model extends BaseModel { ...@@ -196,17 +196,7 @@ abstract class Model extends BaseModel {
*/ */
protected function getDateFormat() protected function getDateFormat()
{ {
return 'Y-m-d H:i:s'; return $this->dateFormat ?: 'Y-m-d H:i:s';
}
/**
* Get a fresh timestamp for the model.
*
* @return MongoDate
*/
public function freshTimestamp()
{
return new MongoDate;
} }
/** /**
...@@ -216,9 +206,7 @@ abstract class Model extends BaseModel { ...@@ -216,9 +206,7 @@ abstract class Model extends BaseModel {
*/ */
public function getTable() public function getTable()
{ {
if (isset($this->collection)) return $this->collection; return $this->collection ?: parent::getTable();
return parent::getTable();
} }
/** /**
......
...@@ -620,7 +620,7 @@ class Builder extends BaseBuilder { ...@@ -620,7 +620,7 @@ class Builder extends BaseBuilder {
return $item; return $item;
}); });
return $results->lists($column, $key); return $results->lists($column, $key)->all();
} }
return parent::lists($column, $key); return parent::lists($column, $key);
......
...@@ -212,6 +212,11 @@ abstract class EmbedsOneOrMany extends Relation { ...@@ -212,6 +212,11 @@ abstract class EmbedsOneOrMany extends Relation {
*/ */
protected function getIdsArrayFrom($ids) protected function getIdsArrayFrom($ids)
{ {
if ($ids instanceof Collection)
{
$ids = $ids->all();
}
if ( ! is_array($ids)) $ids = [$ids]; if ( ! is_array($ids)) $ids = [$ids];
foreach ($ids as &$id) foreach ($ids as &$id)
......
This diff is collapsed.
...@@ -231,7 +231,7 @@ class ModelTest extends TestCase { ...@@ -231,7 +231,7 @@ class ModelTest extends TestCase {
$this->assertEquals('Jane Poe', $user->name); $this->assertEquals('Jane Poe', $user->name);
$check = User::where('name', 'Jane Poe')->first(); $check = User::where('name', 'Jane Poe')->first();
$this->assertEquals($user, $check); $this->assertEquals($user->_id, $check->_id);
} }
public function testDestroy() public function testDestroy()
...@@ -380,8 +380,8 @@ class ModelTest extends TestCase { ...@@ -380,8 +380,8 @@ class ModelTest extends TestCase {
// test custom date format for json output // test custom date format for json output
$json = $user->toArray(); $json = $user->toArray();
$this->assertEquals((string) $user->birthday, $json['birthday']); $this->assertEquals($user->birthday->format('l jS \of F Y h:i:s A'), $json['birthday']);
$this->assertEquals((string) $user->created_at, $json['created_at']); $this->assertEquals($user->created_at->format('l jS \of F Y h:i:s A'), $json['created_at']);
// test default date format for json output // test default date format for json output
$item = Item::create(['name' => 'sword']); $item = Item::create(['name' => 'sword']);
......
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