Commit 4cd4317e authored by jim_reed's avatar jim_reed

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

parents d795dac3 e998cd0a
sudo: required language: minimal
dist: trusty
language: php matrix:
php: include:
- "7.2" - name: "7.1"
- "7.1" env: PHP_VERSION=7.1
- name: "7.2"
env: PHP_VERSION=7.2
- name: "7.3"
env: PHP_VERSION=7.3
services: services:
- docker - docker
cache:
directories:
- $HOME/.composer/cache
install: install:
- docker version - docker version
- sudo pip install docker-compose - sudo pip install docker-compose
- docker-compose version - docker-compose version
- cat Dockerfile - docker-compose build --build-arg PHP_VERSION=${PHP_VERSION}
- docker-compose build --build-arg PHP_VERSION=${TRAVIS_PHP_VERSION} - docker-compose run --rm tests composer install --no-interaction
script: 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 PHP_VERSION=7.2
ARG COMPOSER_VERSION=1.8
FROM composer:${COMPOSER_VERSION}
FROM php:${PHP_VERSION}-cli FROM php:${PHP_VERSION}-cli
RUN pecl install xdebug
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y autoconf pkg-config libssl-dev git zlib1g-dev apt-get install -y autoconf pkg-config libssl-dev git libzip-dev zlib1g-dev && \
pecl install mongodb && docker-php-ext-enable mongodb && \
RUN pecl install mongodb && docker-php-ext-enable mongodb && \ pecl install xdebug && docker-php-ext-enable xdebug && \
docker-php-ext-install -j$(nproc) pdo pdo_mysql zip && docker-php-ext-enable xdebug docker-php-ext-install -j$(nproc) pdo_mysql zip
RUN curl -sS https://getcomposer.org/installer | php \ COPY --from=composer /usr/bin/composer /usr/local/bin/composer
&& mv composer.phar /usr/local/bin/ \
&& ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" WORKDIR /code
...@@ -43,6 +43,8 @@ composer require jenssegers/mongodb ...@@ -43,6 +43,8 @@ composer require jenssegers/mongodb
5.4.x | 3.2.x 5.4.x | 3.2.x
5.5.x | 3.3.x 5.5.x | 3.3.x
5.6.x | 3.4.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`: 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 ...@@ -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: For usage outside Laravel, check out the [Capsule manager](https://github.com/illuminate/database/blob/master/README.md) and add:
```php ```php
$capsule->getDatabaseManager()->extend('mongodb', function($config) $capsule->getDatabaseManager()->extend('mongodb', function($config, $name)
{ {
$config['name'] = $name;
return new Jenssegers\Mongodb\Connection($config); return new Jenssegers\Mongodb\Connection($config);
}); });
``` ```
...@@ -298,7 +302,7 @@ This service provider will slightly modify the internal DatabaseReminderReposito ...@@ -298,7 +302,7 @@ This service provider will slightly modify the internal DatabaseReminderReposito
### Queues ### 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 ```php
'connections' => [ 'connections' => [
...@@ -689,7 +693,7 @@ For more information about model manipulation, check http://laravel.com/docs/elo ...@@ -689,7 +693,7 @@ For more information about model manipulation, check http://laravel.com/docs/elo
### Dates ### 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: Example:
...@@ -787,7 +791,7 @@ class User extends Eloquent { ...@@ -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 ```php
$books = User::first()->books; $books = User::first()->books;
...@@ -849,7 +853,7 @@ Embedded relations will return a Collection of embedded items instead of a query ...@@ -849,7 +853,7 @@ Embedded relations will return a Collection of embedded items instead of a query
### EmbedsOne Relations ### 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 ```php
use Jenssegers\Mongodb\Eloquent\Model as Eloquent; use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
...@@ -864,7 +868,7 @@ class Book extends 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 ```php
$author = Book::first()->author; $author = Book::first()->author;
...@@ -1014,7 +1018,7 @@ DB::collection('items')->paginate($limit, $projections); ...@@ -1014,7 +1018,7 @@ DB::collection('items')->paginate($limit, $projections);
**Push** **Push**
Add an items to an array. Add items to an array.
```php ```php
DB::collection('users')->where('name', 'John')->push('items', 'boots'); DB::collection('users')->where('name', 'John')->push('items', 'boots');
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
], ],
"license" : "MIT", "license" : "MIT",
"require": { "require": {
"illuminate/support": "^5.6", "illuminate/support": "^5.8",
"illuminate/container": "^5.6", "illuminate/container": "^5.8",
"illuminate/database": "^5.6", "illuminate/database": "^5.8",
"illuminate/events": "^5.6", "illuminate/events": "^5.8",
"mongodb/mongodb": "^1.0.0" "mongodb/mongodb": "^1.4"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6.0|^7.0", "phpunit/phpunit": "^6.0|^7.0",
......
version: '3' version: '3'
services: services:
php: tests:
container_name: php container_name: tests
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
volumes: volumes:
- .:/code - .:/code
working_dir: /code working_dir: /code
command: bash -c "composer install --prefer-source --no-interaction && php ./vendor/bin/phpunit"
depends_on: depends_on:
- mysql
- mongodb - mongodb
- mysql
mysql: mysql:
container_name: mysql container_name: mysql
image: mysql image: mysql:5.7
environment: environment:
MYSQL_ROOT_PASSWORD: MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: unittest MYSQL_DATABASE: unittest
...@@ -27,5 +26,7 @@ services: ...@@ -27,5 +26,7 @@ services:
mongodb: mongodb:
container_name: mongodb container_name: mongodb
image: mongo image: mongo
ports:
- 27017:27017
logging: logging:
driver: none driver: none
...@@ -8,13 +8,11 @@ ...@@ -8,13 +8,11 @@
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
syntaxCheck="false"
verbose="true" verbose="true"
> >
<testsuites> <testsuites>
<testsuite name="all"> <testsuite name="all">
<directory>tests/</directory> <directory>tests/</directory>
<exclude>tests/MysqlRelationsTest.php</exclude>
</testsuite> </testsuite>
<testsuite name="schema"> <testsuite name="schema">
<directory>tests/SchemaTest.php</directory> <directory>tests/SchemaTest.php</directory>
...@@ -39,7 +37,6 @@ ...@@ -39,7 +37,6 @@
</testsuite> </testsuite>
<testsuite name="mysqlrelations"> <testsuite name="mysqlrelations">
<directory>tests/RelationsTest.php</directory> <directory>tests/RelationsTest.php</directory>
<directory>tests/MysqlRelationsTest.php</directory>
</testsuite> </testsuite>
<testsuite name="validation"> <testsuite name="validation">
<directory>tests/ValidationTest.php</directory> <directory>tests/ValidationTest.php</directory>
......
...@@ -11,14 +11,6 @@ class PasswordBrokerManager extends BasePasswordBrokerManager ...@@ -11,14 +11,6 @@ class PasswordBrokerManager extends BasePasswordBrokerManager
*/ */
protected function createTokenRepository(array $config) 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( return new DatabaseTokenRepository(
$this->app['db']->connection(), $this->app['db']->connection(),
$this->app['hash'], $this->app['hash'],
......
...@@ -113,6 +113,14 @@ class Connection extends BaseConnection ...@@ -113,6 +113,14 @@ class Connection extends BaseConnection
return $this->connection; return $this->connection;
} }
/**
* {@inheritdoc}
*/
public function getDatabaseName()
{
return $this->getMongoDB()->getDatabaseName();
}
/** /**
* Create a new MongoDB connection. * Create a new MongoDB connection.
* *
......
...@@ -177,6 +177,31 @@ class Builder extends EloquentBuilder ...@@ -177,6 +177,31 @@ class Builder extends EloquentBuilder
return $results; 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 * @return \Illuminate\Database\ConnectionInterface
*/ */
......
...@@ -32,6 +32,13 @@ abstract class Model extends BaseModel ...@@ -32,6 +32,13 @@ abstract class Model extends BaseModel
*/ */
protected $primaryKey = '_id'; protected $primaryKey = '_id';
/**
* The primary key type.
*
* @var string
*/
protected $keyType = 'string';
/** /**
* The parent relation instance. * The parent relation instance.
* *
...@@ -221,7 +228,7 @@ abstract class Model extends BaseModel ...@@ -221,7 +228,7 @@ abstract class Model extends BaseModel
/** /**
* @inheritdoc * @inheritdoc
*/ */
protected function originalIsEquivalent($key, $current) public function originalIsEquivalent($key, $current)
{ {
if (!array_key_exists($key, $this->original)) { if (!array_key_exists($key, $this->original)) {
return false; return false;
......
...@@ -110,7 +110,7 @@ trait QueriesRelationships ...@@ -110,7 +110,7 @@ trait QueriesRelationships
} }
if ($relation instanceof BelongsTo) { if ($relation instanceof BelongsTo) {
return $relation->getForeignKey(); return $relation->getForeignKeyName();
} }
if ($relation instanceof BelongsToMany && ! $this->isAcrossConnections($relation)) { if ($relation instanceof BelongsToMany && ! $this->isAcrossConnections($relation)) {
...@@ -130,7 +130,7 @@ trait QueriesRelationships ...@@ -130,7 +130,7 @@ trait QueriesRelationships
return $relation->getHasCompareKey(); return $relation->getHasCompareKey();
} }
return $relation instanceof HasOneOrMany ? $relation->getForeignKeyName() : $relation->getOwnerKey(); return $relation instanceof HasOneOrMany ? $relation->getForeignKeyName() : $relation->getOwnerKeyName();
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Jenssegers\Mongodb\Relations; namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
...@@ -59,4 +60,16 @@ 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; 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; ...@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class BelongsToMany extends EloquentBelongsToMany class BelongsToMany extends EloquentBelongsToMany
{ {
...@@ -337,4 +338,16 @@ class BelongsToMany extends EloquentBelongsToMany ...@@ -337,4 +338,16 @@ class BelongsToMany extends EloquentBelongsToMany
{ {
return property_exists($this, 'relatedPivotKey') ? $this->relatedPivotKey : $this->relatedKey; 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; ...@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator; use Illuminate\Pagination\Paginator;
use MongoDB\BSON\ObjectID; use MongoDB\BSON\ObjectID;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class EmbedsMany extends EmbedsOneOrMany class EmbedsMany extends EmbedsOneOrMany
{ {
...@@ -328,4 +329,16 @@ class EmbedsMany extends EmbedsOneOrMany ...@@ -328,4 +329,16 @@ class EmbedsMany extends EmbedsOneOrMany
return parent::__call($method, $parameters); 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; ...@@ -4,6 +4,7 @@ namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use MongoDB\BSON\ObjectID; use MongoDB\BSON\ObjectID;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class EmbedsOne extends EmbedsOneOrMany class EmbedsOne extends EmbedsOneOrMany
{ {
...@@ -136,4 +137,16 @@ class EmbedsOne extends EmbedsOneOrMany ...@@ -136,4 +137,16 @@ class EmbedsOne extends EmbedsOneOrMany
{ {
return $this->performDelete(); 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; ...@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\Eloquent\Relations\Relation;
use Jenssegers\Mongodb\Eloquent\Model; use Jenssegers\Mongodb\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as EloquentModel;
abstract class EmbedsOneOrMany extends Relation abstract class EmbedsOneOrMany extends Relation
{ {
...@@ -403,4 +404,16 @@ abstract class EmbedsOneOrMany extends Relation ...@@ -403,4 +404,16 @@ abstract class EmbedsOneOrMany extends Relation
{ {
return $this->foreignKey; 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; ...@@ -4,6 +4,7 @@ namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany as EloquentHasMany; use Illuminate\Database\Eloquent\Relations\HasMany as EloquentHasMany;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class HasMany extends EloquentHasMany class HasMany extends EloquentHasMany
{ {
...@@ -77,4 +78,16 @@ class HasMany extends EloquentHasMany ...@@ -77,4 +78,16 @@ class HasMany extends EloquentHasMany
return $query->where($this->getHasCompareKey(), 'exists', true); 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; ...@@ -4,6 +4,7 @@ namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasOne as EloquentHasOne; use Illuminate\Database\Eloquent\Relations\HasOne as EloquentHasOne;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class HasOne extends EloquentHasOne class HasOne extends EloquentHasOne
{ {
...@@ -77,4 +78,16 @@ class HasOne extends EloquentHasOne ...@@ -77,4 +78,16 @@ class HasOne extends EloquentHasOne
return $query->where($this->getForeignKeyName(), 'exists', true); 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 @@ ...@@ -3,6 +3,7 @@
namespace Jenssegers\Mongodb\Relations; namespace Jenssegers\Mongodb\Relations;
use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo; use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class MorphTo extends EloquentMorphTo class MorphTo extends EloquentMorphTo
{ {
...@@ -42,4 +43,16 @@ class MorphTo extends EloquentMorphTo ...@@ -42,4 +43,16 @@ class MorphTo extends EloquentMorphTo
{ {
return property_exists($this, 'ownerKey') ? $this->ownerKey : $this->otherKey; 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 ...@@ -85,11 +85,11 @@ class Builder extends \Illuminate\Database\Schema\Builder
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function create($collection, Closure $callback = null) public function create($collection, Closure $callback = null, array $options = [])
{ {
$blueprint = $this->createBlueprint($collection); $blueprint = $this->createBlueprint($collection);
$blueprint->create(); $blueprint->create($options);
if ($callback) { if ($callback) {
$callback($blueprint); $callback($blueprint);
......
...@@ -5,8 +5,9 @@ use Illuminate\Foundation\Application; ...@@ -5,8 +5,9 @@ use Illuminate\Foundation\Application;
class AuthTest extends TestCase class AuthTest extends TestCase
{ {
public function tearDown() public function tearDown(): void
{ {
parent::setUp();
User::truncate(); User::truncate();
DB::collection('password_reminders')->truncate(); DB::collection('password_reminders')->truncate();
} }
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class GeospatialTest extends TestCase class GeospatialTest extends TestCase
{ {
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
...@@ -43,7 +43,7 @@ class GeospatialTest extends TestCase ...@@ -43,7 +43,7 @@ class GeospatialTest extends TestCase
]); ]);
} }
public function tearDown() public function tearDown(): void
{ {
Schema::drop('locations'); Schema::drop('locations');
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class HybridRelationsTest extends TestCase class HybridRelationsTest extends TestCase
{ {
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
...@@ -11,7 +11,7 @@ class HybridRelationsTest extends TestCase ...@@ -11,7 +11,7 @@ class HybridRelationsTest extends TestCase
MysqlRole::executeSchema(); MysqlRole::executeSchema();
} }
public function tearDown() public function tearDown(): void
{ {
MysqlUser::truncate(); MysqlUser::truncate();
MysqlBook::truncate(); MysqlBook::truncate();
......
...@@ -8,7 +8,7 @@ use MongoDB\BSON\UTCDateTime; ...@@ -8,7 +8,7 @@ use MongoDB\BSON\UTCDateTime;
class ModelTest extends TestCase class ModelTest extends TestCase
{ {
public function tearDown() public function tearDown(): void
{ {
User::truncate(); User::truncate();
Soft::truncate(); Soft::truncate();
...@@ -262,7 +262,6 @@ class ModelTest extends TestCase ...@@ -262,7 +262,6 @@ class ModelTest extends TestCase
$user->save(); $user->save();
$old = $user->updated_at; $old = $user->updated_at;
sleep(1); sleep(1);
$user->touch(); $user->touch();
$check = User::find($user->_id); $check = User::find($user->_id);
......
...@@ -5,7 +5,7 @@ use MongoDB\BSON\Regex; ...@@ -5,7 +5,7 @@ use MongoDB\BSON\Regex;
class QueryBuilderTest extends TestCase class QueryBuilderTest extends TestCase
{ {
public function tearDown() public function tearDown(): void
{ {
DB::collection('users')->truncate(); DB::collection('users')->truncate();
DB::collection('items')->truncate(); DB::collection('items')->truncate();
......
...@@ -4,7 +4,7 @@ class QueryTest extends TestCase ...@@ -4,7 +4,7 @@ class QueryTest extends TestCase
{ {
protected static $started = false; protected static $started = false;
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
User::create(['name' => 'John Doe', 'age' => 35, 'title' => 'admin']); User::create(['name' => 'John Doe', 'age' => 35, 'title' => 'admin']);
...@@ -18,7 +18,7 @@ class QueryTest extends TestCase ...@@ -18,7 +18,7 @@ class QueryTest extends TestCase
User::create(['name' => 'Error', 'age' => null, 'title' => null]); User::create(['name' => 'Error', 'age' => null, 'title' => null]);
} }
public function tearDown() public function tearDown(): void
{ {
User::truncate(); User::truncate();
parent::tearDown(); parent::tearDown();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class QueueTest extends TestCase class QueueTest extends TestCase
{ {
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class RelationsTest extends TestCase class RelationsTest extends TestCase
{ {
public function tearDown() public function tearDown(): void
{ {
Mockery::close(); Mockery::close();
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
class SchemaTest extends TestCase class SchemaTest extends TestCase
{ {
public function tearDown() public function tearDown(): void
{ {
Schema::drop('newcollection'); Schema::drop('newcollection');
Schema::drop('newcollection_two');
} }
public function testCreate() public function testCreate()
...@@ -25,6 +26,13 @@ class SchemaTest extends TestCase ...@@ -25,6 +26,13 @@ class SchemaTest extends TestCase
$this->assertTrue(Schema::hasCollection('newcollection')); $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() public function testDrop()
{ {
Schema::create('newcollection'); Schema::create('newcollection');
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class SeederTest extends TestCase class SeederTest extends TestCase
{ {
public function tearDown() public function tearDown(): void
{ {
User::truncate(); User::truncate();
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class ValidationTest extends TestCase class ValidationTest extends TestCase
{ {
public function tearDown() public function tearDown(): void
{ {
User::truncate(); 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