Commit bd26b77b authored by Jens Segers's avatar Jens Segers

Running tests on Laravel 5.1

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