Commit 4cd4317e authored by jim_reed's avatar jim_reed

Merge remote-tracking branch 'origin/master' into patch-2

parents d795dac3 e998cd0a
sudo: required
dist: trusty
language: php
php:
- "7.2"
- "7.1"
language: minimal
matrix:
include:
- name: "7.1"
env: PHP_VERSION=7.1
- name: "7.2"
env: PHP_VERSION=7.2
- name: "7.3"
env: PHP_VERSION=7.3
services:
- docker
cache:
directories:
- $HOME/.composer/cache
install:
- docker version
- sudo pip install docker-compose
- docker-compose version
- cat Dockerfile
- docker-compose build --build-arg PHP_VERSION=${TRAVIS_PHP_VERSION}
- docker-compose build --build-arg PHP_VERSION=${PHP_VERSION}
- docker-compose run --rm tests composer install --no-interaction
script:
- docker-compose up --exit-code-from php
- docker-compose run --rm tests ./vendor/bin/phpunit --coverage-clover ./clover.xml
ARG PHP_VERSION=7.2
ARG COMPOSER_VERSION=1.8
FROM composer:${COMPOSER_VERSION}
FROM php:${PHP_VERSION}-cli
RUN pecl install xdebug
RUN apt-get update && \
apt-get install -y autoconf pkg-config libssl-dev git zlib1g-dev
RUN pecl install mongodb && docker-php-ext-enable mongodb && \
docker-php-ext-install -j$(nproc) pdo pdo_mysql zip && docker-php-ext-enable xdebug
apt-get install -y autoconf pkg-config libssl-dev git libzip-dev zlib1g-dev && \
pecl install mongodb && docker-php-ext-enable mongodb && \
pecl install xdebug && docker-php-ext-enable xdebug && \
docker-php-ext-install -j$(nproc) pdo_mysql zip
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/ \
&& ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}"
WORKDIR /code
......@@ -43,6 +43,8 @@ composer require jenssegers/mongodb
5.4.x | 3.2.x
5.5.x | 3.3.x
5.6.x | 3.4.x
5.7.x | 3.4.x
5.8.x | 3.5.x
And add the service provider in `config/app.php`:
......@@ -63,8 +65,10 @@ The service provider will register a mongodb database extension with the origina
For usage outside Laravel, check out the [Capsule manager](https://github.com/illuminate/database/blob/master/README.md) and add:
```php
$capsule->getDatabaseManager()->extend('mongodb', function($config)
$capsule->getDatabaseManager()->extend('mongodb', function($config, $name)
{
$config['name'] = $name;
return new Jenssegers\Mongodb\Connection($config);
});
```
......@@ -298,7 +302,7 @@ This service provider will slightly modify the internal DatabaseReminderReposito
### Queues
If you want to use MongoDB as your database backend, change the the driver in `config/queue.php`:
If you want to use MongoDB as your database backend, change the driver in `config/queue.php`:
```php
'connections' => [
......@@ -689,7 +693,7 @@ For more information about model manipulation, check http://laravel.com/docs/elo
### Dates
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields, you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators
Example:
......@@ -787,7 +791,7 @@ class User extends Eloquent {
}
```
You access the embedded models through the dynamic property:
You can access the embedded models through the dynamic property:
```php
$books = User::first()->books;
......@@ -849,7 +853,7 @@ Embedded relations will return a Collection of embedded items instead of a query
### EmbedsOne Relations
The embedsOne relation is similar to the EmbedsMany relation, but only embeds a single model.
The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.
```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
......@@ -864,7 +868,7 @@ class Book extends Eloquent {
}
```
You access the embedded models through the dynamic property:
You can access the embedded models through the dynamic property:
```php
$author = Book::first()->author;
......@@ -1014,7 +1018,7 @@ DB::collection('items')->paginate($limit, $projections);
**Push**
Add an items to an array.
Add items to an array.
```php
DB::collection('users')->where('name', 'John')->push('items', 'boots');
......
......@@ -11,11 +11,11 @@
],
"license" : "MIT",
"require": {
"illuminate/support": "^5.6",
"illuminate/container": "^5.6",
"illuminate/database": "^5.6",
"illuminate/events": "^5.6",
"mongodb/mongodb": "^1.0.0"
"illuminate/support": "^5.8",
"illuminate/container": "^5.8",
"illuminate/database": "^5.8",
"illuminate/events": "^5.8",
"mongodb/mongodb": "^1.4"
},
"require-dev": {
"phpunit/phpunit": "^6.0|^7.0",
......
version: '3'
services:
php:
container_name: php
tests:
container_name: tests
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/code
working_dir: /code
command: bash -c "composer install --prefer-source --no-interaction && php ./vendor/bin/phpunit"
depends_on:
- mysql
- mongodb
- mysql
mysql:
container_name: mysql
image: mysql
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: unittest
......@@ -27,5 +26,7 @@ services:
mongodb:
container_name: mongodb
image: mongo
ports:
- 27017:27017
logging:
driver: none
......@@ -8,13 +8,11 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true"
>
<testsuites>
<testsuite name="all">
<directory>tests/</directory>
<exclude>tests/MysqlRelationsTest.php</exclude>
</testsuite>
<testsuite name="schema">
<directory>tests/SchemaTest.php</directory>
......@@ -39,7 +37,6 @@
</testsuite>
<testsuite name="mysqlrelations">
<directory>tests/RelationsTest.php</directory>
<directory>tests/MysqlRelationsTest.php</directory>
</testsuite>
<testsuite name="validation">
<directory>tests/ValidationTest.php</directory>
......
......@@ -11,14 +11,6 @@ class PasswordBrokerManager extends BasePasswordBrokerManager
*/
protected function createTokenRepository(array $config)
{
$key = $this->app['config']['app.key'];
if (\Illuminate\Support\Str::startsWith($key, 'base64:')) {
$key = base64_decode(substr($key, 7));
}
$connection = isset($config['connection']) ? $config['connection'] : null;
return new DatabaseTokenRepository(
$this->app['db']->connection(),
$this->app['hash'],
......
......@@ -113,6 +113,14 @@ class Connection extends BaseConnection
return $this->connection;
}
/**
* {@inheritdoc}
*/
public function getDatabaseName()
{
return $this->getMongoDB()->getDatabaseName();
}
/**
* Create a new MongoDB connection.
*
......
......@@ -177,6 +177,31 @@ class Builder extends EloquentBuilder
return $results;
}
/**
* Add the "updated at" column to an array of values.
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
* wiil be reverted
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791
*
* @param array $values
* @return array
*/
protected function addUpdatedAtColumn(array $values)
{
if (! $this->model->usesTimestamps() ||
is_null($this->model->getUpdatedAtColumn())) {
return $values;
}
$column = $this->model->getUpdatedAtColumn();
$values = array_merge(
[$column => $this->model->freshTimestampString()],
$values
);
return $values;
}
/**
* @return \Illuminate\Database\ConnectionInterface
*/
......
......@@ -31,6 +31,13 @@ abstract class Model extends BaseModel
* @var string
*/
protected $primaryKey = '_id';
/**
* The primary key type.
*
* @var string
*/
protected $keyType = 'string';
/**
* The parent relation instance.
......@@ -221,7 +228,7 @@ abstract class Model extends BaseModel
/**
* @inheritdoc
*/
protected function originalIsEquivalent($key, $current)
public function originalIsEquivalent($key, $current)
{
if (!array_key_exists($key, $this->original)) {
return false;
......
......@@ -110,7 +110,7 @@ trait QueriesRelationships
}
if ($relation instanceof BelongsTo) {
return $relation->getForeignKey();
return $relation->getForeignKeyName();
}
if ($relation instanceof BelongsToMany && ! $this->isAcrossConnections($relation)) {
......@@ -130,7 +130,7 @@ trait QueriesRelationships
return $relation->getHasCompareKey();
}
return $relation instanceof HasOneOrMany ? $relation->getForeignKeyName() : $relation->getOwnerKey();
return $relation instanceof HasOneOrMany ? $relation->getForeignKeyName() : $relation->getOwnerKeyName();
}
/**
......
......@@ -3,6 +3,7 @@
namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
{
......@@ -59,4 +60,16 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return property_exists($this, 'ownerKey') ? $this->ownerKey : $this->otherKey;
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany;
use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class BelongsToMany extends EloquentBelongsToMany
{
......@@ -337,4 +338,16 @@ class BelongsToMany extends EloquentBelongsToMany
{
return property_exists($this, 'relatedPivotKey') ? $this->relatedPivotKey : $this->relatedKey;
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use MongoDB\BSON\ObjectID;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class EmbedsMany extends EmbedsOneOrMany
{
......@@ -328,4 +329,16 @@ class EmbedsMany extends EmbedsOneOrMany
return parent::__call($method, $parameters);
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -4,6 +4,7 @@ namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Model;
use MongoDB\BSON\ObjectID;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class EmbedsOne extends EmbedsOneOrMany
{
......@@ -136,4 +137,16 @@ class EmbedsOne extends EmbedsOneOrMany
{
return $this->performDelete();
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation;
use Jenssegers\Mongodb\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as EloquentModel;
abstract class EmbedsOneOrMany extends Relation
{
......@@ -403,4 +404,16 @@ abstract class EmbedsOneOrMany extends Relation
{
return $this->foreignKey;
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -4,6 +4,7 @@ namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany as EloquentHasMany;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class HasMany extends EloquentHasMany
{
......@@ -77,4 +78,16 @@ class HasMany extends EloquentHasMany
return $query->where($this->getHasCompareKey(), 'exists', true);
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -4,6 +4,7 @@ namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasOne as EloquentHasOne;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class HasOne extends EloquentHasOne
{
......@@ -77,4 +78,16 @@ class HasOne extends EloquentHasOne
return $query->where($this->getForeignKeyName(), 'exists', true);
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -3,6 +3,7 @@
namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class MorphTo extends EloquentMorphTo
{
......@@ -42,4 +43,16 @@ class MorphTo extends EloquentMorphTo
{
return property_exists($this, 'ownerKey') ? $this->ownerKey : $this->otherKey;
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(EloquentModel $model, $key)
{
return 'whereIn';
}
}
......@@ -85,11 +85,11 @@ class Builder extends \Illuminate\Database\Schema\Builder
/**
* @inheritdoc
*/
public function create($collection, Closure $callback = null)
public function create($collection, Closure $callback = null, array $options = [])
{
$blueprint = $this->createBlueprint($collection);
$blueprint->create();
$blueprint->create($options);
if ($callback) {
$callback($blueprint);
......
......@@ -5,8 +5,9 @@ use Illuminate\Foundation\Application;
class AuthTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
parent::setUp();
User::truncate();
DB::collection('password_reminders')->truncate();
}
......
......@@ -2,7 +2,7 @@
class EmbeddedRelationsTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
Mockery::close();
......@@ -21,11 +21,11 @@ class EmbeddedRelationsTest extends TestCase
$address = new Address(['city' => 'London']);
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(true);
$events->shouldReceive('fire')->once()->with('eloquent.created: ' . get_class($address), $address);
$events->shouldReceive('fire')->once()->with('eloquent.saved: ' . get_class($address), $address);
$events->shouldReceive('dispatch')->once()->with('eloquent.created: ' . get_class($address), $address);
$events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($address), $address);
$address = $user->addresses()->save($address);
$address->unsetEventDispatcher();
......@@ -47,11 +47,11 @@ class EmbeddedRelationsTest extends TestCase
$this->assertEquals(['London', 'Paris'], $user->addresses->pluck('city')->all());
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
$events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(true);
$events->shouldReceive('fire')->once()->with('eloquent.updated: ' . get_class($address), $address);
$events->shouldReceive('fire')->once()->with('eloquent.saved: ' . get_class($address), $address);
$events->shouldReceive('dispatch')->once()->with('eloquent.updated: ' . get_class($address), $address);
$events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($address), $address);
$address->city = 'New York';
$user->addresses()->save($address);
......@@ -94,16 +94,16 @@ class EmbeddedRelationsTest extends TestCase
// $address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
// $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
// $events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(true);
// $events->shouldReceive('fire')->once()->with('eloquent.created: ' . get_class($address), $address);
// $events->shouldReceive('fire')->once()->with('eloquent.saved: ' . get_class($address), $address);
// $events->shouldReceive('dispatch')->once()->with('eloquent.created: ' . get_class($address), $address);
// $events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($address), $address);
// $address->save();
// $address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
// $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
// $events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(true);
// $events->shouldReceive('fire')->once()->with('eloquent.updated: ' . get_class($address), $address);
// $events->shouldReceive('fire')->once()->with('eloquent.saved: ' . get_class($address), $address);
// $events->shouldReceive('dispatch')->once()->with('eloquent.updated: ' . get_class($address), $address);
// $events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($address), $address);
// $address->city = 'Paris';
// $address->save();
......@@ -213,9 +213,9 @@ class EmbeddedRelationsTest extends TestCase
$address = $user->addresses->first();
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::type('Address'))->andReturn(true);
$events->shouldReceive('fire')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address'));
$events->shouldReceive('dispatch')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address'));
$user->addresses()->destroy($address->_id);
$this->assertEquals(['Bristol', 'Bruxelles'], $user->addresses->pluck('city')->all());
......@@ -252,9 +252,9 @@ class EmbeddedRelationsTest extends TestCase
$address = $user->addresses->first();
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::type('Address'))->andReturn(true);
$events->shouldReceive('fire')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address'));
$events->shouldReceive('dispatch')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address'));
$address->delete();
......@@ -301,7 +301,7 @@ class EmbeddedRelationsTest extends TestCase
$address = new Address(['city' => 'London']);
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(false);
......@@ -316,7 +316,7 @@ class EmbeddedRelationsTest extends TestCase
$address->exists = true;
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(false);
$this->assertFalse($user->addresses()->save($address));
......@@ -330,7 +330,7 @@ class EmbeddedRelationsTest extends TestCase
$user->addresses()->save($address);
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
$events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(false);
......@@ -348,7 +348,7 @@ class EmbeddedRelationsTest extends TestCase
$address = $user->addresses->first();
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::mustBe($address))->andReturn(false);
$this->assertEquals(0, $user->addresses()->destroy($address));
......@@ -452,11 +452,11 @@ class EmbeddedRelationsTest extends TestCase
$father = new User(['name' => 'Mark Doe']);
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true);
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($father), $father)->andReturn(true);
$events->shouldReceive('fire')->once()->with('eloquent.created: ' . get_class($father), $father);
$events->shouldReceive('fire')->once()->with('eloquent.saved: ' . get_class($father), $father);
$events->shouldReceive('dispatch')->once()->with('eloquent.created: ' . get_class($father), $father);
$events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($father), $father);
$father = $user->father()->save($father);
$father->unsetEventDispatcher();
......@@ -472,11 +472,11 @@ class EmbeddedRelationsTest extends TestCase
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $raw['_id']);
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true);
$events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($father), $father)->andReturn(true);
$events->shouldReceive('fire')->once()->with('eloquent.updated: ' . get_class($father), $father);
$events->shouldReceive('fire')->once()->with('eloquent.saved: ' . get_class($father), $father);
$events->shouldReceive('dispatch')->once()->with('eloquent.updated: ' . get_class($father), $father);
$events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($father), $father);
$father->name = 'Tom Doe';
$user->father()->save($father);
......@@ -488,11 +488,11 @@ class EmbeddedRelationsTest extends TestCase
$father = new User(['name' => 'Jim Doe']);
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true);
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($father), $father)->andReturn(true);
$events->shouldReceive('fire')->once()->with('eloquent.created: ' . get_class($father), $father);
$events->shouldReceive('fire')->once()->with('eloquent.saved: ' . get_class($father), $father);
$events->shouldReceive('dispatch')->once()->with('eloquent.created: ' . get_class($father), $father);
$events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($father), $father);
$father = $user->father()->save($father);
$father->unsetEventDispatcher();
......@@ -507,7 +507,7 @@ class EmbeddedRelationsTest extends TestCase
$father = new User(['name' => 'Mark Doe']);
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
$events->shouldReceive('until')->times(0)->with('eloquent.saving: ' . get_class($father), $father);
$father = $user->father()->associate($father);
......
......@@ -2,7 +2,7 @@
class GeospatialTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
......@@ -43,7 +43,7 @@ class GeospatialTest extends TestCase
]);
}
public function tearDown()
public function tearDown(): void
{
Schema::drop('locations');
}
......
......@@ -2,7 +2,7 @@
class HybridRelationsTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
......@@ -11,7 +11,7 @@ class HybridRelationsTest extends TestCase
MysqlRole::executeSchema();
}
public function tearDown()
public function tearDown(): void
{
MysqlUser::truncate();
MysqlBook::truncate();
......
......@@ -8,7 +8,7 @@ use MongoDB\BSON\UTCDateTime;
class ModelTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
User::truncate();
Soft::truncate();
......@@ -262,7 +262,6 @@ class ModelTest extends TestCase
$user->save();
$old = $user->updated_at;
sleep(1);
$user->touch();
$check = User::find($user->_id);
......
......@@ -5,7 +5,7 @@ use MongoDB\BSON\Regex;
class QueryBuilderTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
DB::collection('users')->truncate();
DB::collection('items')->truncate();
......
......@@ -4,7 +4,7 @@ class QueryTest extends TestCase
{
protected static $started = false;
public function setUp()
public function setUp(): void
{
parent::setUp();
User::create(['name' => 'John Doe', 'age' => 35, 'title' => 'admin']);
......@@ -18,7 +18,7 @@ class QueryTest extends TestCase
User::create(['name' => 'Error', 'age' => null, 'title' => null]);
}
public function tearDown()
public function tearDown(): void
{
User::truncate();
parent::tearDown();
......
......@@ -2,7 +2,7 @@
class QueueTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
......
......@@ -2,7 +2,7 @@
class RelationsTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
Mockery::close();
......
......@@ -2,9 +2,10 @@
class SchemaTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
Schema::drop('newcollection');
Schema::drop('newcollection_two');
}
public function testCreate()
......@@ -25,6 +26,13 @@ class SchemaTest extends TestCase
$this->assertTrue(Schema::hasCollection('newcollection'));
}
public function testCreateWithOptions()
{
Schema::create('newcollection_two', null, ['capped' => true, 'size' => 1024]);
$this->assertTrue(Schema::hasCollection('newcollection_two'));
$this->assertTrue(Schema::hasTable('newcollection_two'));
}
public function testDrop()
{
Schema::create('newcollection');
......
......@@ -2,7 +2,7 @@
class SeederTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
User::truncate();
}
......
......@@ -2,7 +2,7 @@
class ValidationTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
User::truncate();
}
......
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