diff --git a/.travis.yml b/.travis.yml index 27000a962..30972bfb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,32 @@ +sudo: required +dist: trusty language: php - php: - - 7 - - 7.1 - -matrix: - fast_finish: true - -sudo: false + - "7.2" + - "7.1" services: - - mongodb - - mysql - -addons: - apt: - sources: - - mongodb-3.0-precise - packages: - - mongodb-org-server - -before_script: - - pecl install mongodb - - mysql -e 'create database unittest;' - - travis_retry composer self-update - - travis_retry composer install --no-interaction + - docker + +install: + # Update docker-engine using Ubuntu 'trusty' apt repo + - > + curl -sSL "https://get.docker.com/gpg" | + sudo -E apt-key add - + - > + echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | + sudo tee -a /etc/apt/sources.list + - sudo apt-get update + - > + sudo apt-get -o Dpkg::Options::="--force-confdef" \ + -o Dpkg::Options::="--force-confold" --assume-yes install docker-engine --allow-unauthenticated + - docker version + + # Update docker-compose via pip + - sudo pip install docker-compose + - docker-compose version + - docker-compose up --build -d + - docker ps -a script: - - mkdir -p build/logs - - vendor/bin/phpunit --coverage-clover build/logs/clover.xml - -after_success: - - sh -c 'php vendor/bin/coveralls -v' + - docker-compose up --exit-code-from php diff --git a/composer.json b/composer.json index 8655bd45c..ce32f6407 100644 --- a/composer.json +++ b/composer.json @@ -11,14 +11,14 @@ ], "license" : "MIT", "require": { - "illuminate/support": "^5.5", - "illuminate/container": "^5.5", - "illuminate/database": "^5.5", - "illuminate/events": "^5.5", + "illuminate/support": "^5.6", + "illuminate/container": "^5.6", + "illuminate/database": "^5.6", + "illuminate/events": "^5.6", "mongodb/mongodb": "^1.0.0" }, "require-dev": { - "phpunit/phpunit": "^6.0", + "phpunit/phpunit": "^6.0|^7.0", "orchestra/testbench": "^3.1", "mockery/mockery": "^1.0", "satooshi/php-coveralls": "^2.0", diff --git a/docker-compose.yml b/docker-compose.yml index 6c2c773bb..ce5c95652 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: '3' services: php: + container_name: php build: context: . dockerfile: docker/Dockerfile @@ -15,6 +16,7 @@ services: - mongodb mysql: + container_name: mysql image: mysql environment: MYSQL_ROOT_PASSWORD: @@ -24,6 +26,7 @@ services: driver: none mongodb: + container_name: mongodb image: mongo logging: driver: none diff --git a/docker/Dockerfile b/docker/Dockerfile index 0ba057324..62c68e45d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,14 @@ FROM php:7.1-cli +RUN pecl install xdebug + RUN apt-get update && \ - apt-get install -y autoconf pkg-config libssl-dev && \ - pecl install mongodb && docker-php-ext-enable mongodb && \ - docker-php-ext-install -j$(nproc) pdo pdo_mysql + apt-get install -y autoconf pkg-config libssl-dev git && \ + pecl install mongodb git zlib1g-dev && docker-php-ext-enable mongodb && \ + docker-php-ext-install -j$(nproc) pdo pdo_mysql zip && docker-php-ext-enable xdebug + +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 + +ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index ecff3cf08..c646f3917 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -sleep 3 && php ./vendor/bin/phpunit +sleep 3 && composer install --prefer-source --no-interaction && php ./vendor/bin/phpunit diff --git a/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php b/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php index 7f9b511ae..34b8b5788 100644 --- a/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php +++ b/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php @@ -169,9 +169,10 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat * @param string $name * @param string $type * @param string $id + * @param string $ownerKey * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ - public function morphTo($name = null, $type = null, $id = null) + public function morphTo($name = null, $type = null, $id = null, $ownerKey = null) { // If no name is provided, we will use the backtrace to get the function name // since that is most likely the name of the polymorphic interface. We can diff --git a/src/Jenssegers/Mongodb/Eloquent/Model.php b/src/Jenssegers/Mongodb/Eloquent/Model.php index 38b3858f8..86f8ef3b5 100644 --- a/src/Jenssegers/Mongodb/Eloquent/Model.php +++ b/src/Jenssegers/Mongodb/Eloquent/Model.php @@ -101,7 +101,7 @@ protected function asDateTime($value) /** * @inheritdoc */ - protected function getDateFormat() + public function getDateFormat() { return $this->dateFormat ?: 'Y-m-d H:i:s'; } diff --git a/src/Jenssegers/Mongodb/Queue/MongoQueue.php b/src/Jenssegers/Mongodb/Queue/MongoQueue.php index ed7e9c2ed..e9cd8da9c 100644 --- a/src/Jenssegers/Mongodb/Queue/MongoQueue.php +++ b/src/Jenssegers/Mongodb/Queue/MongoQueue.php @@ -117,7 +117,7 @@ protected function releaseJobsThatHaveBeenReservedTooLong($queue) })->get(); foreach ($reserved as $job) { - $attempts = $job['attempts']; + $attempts = $job['attempts'] + 1; $this->releaseJob($job['_id'], $attempts); } } diff --git a/src/Jenssegers/Mongodb/Schema/Builder.php b/src/Jenssegers/Mongodb/Schema/Builder.php index e30e162b7..799fe8e80 100644 --- a/src/Jenssegers/Mongodb/Schema/Builder.php +++ b/src/Jenssegers/Mongodb/Schema/Builder.php @@ -96,6 +96,18 @@ public function create($collection, Closure $callback = null) } } + /** + * @inheritdoc + */ + public function dropIfExists($collection) + { + if ($this->hasCollection($collection)) { + return $this->drop($collection); + } + + return false; + } + /** * @inheritdoc */ diff --git a/tests/models/User.php b/tests/models/User.php index ded0a3966..d233c3f32 100644 --- a/tests/models/User.php +++ b/tests/models/User.php @@ -65,7 +65,7 @@ public function father() return $this->embedsOne('User'); } - protected function getDateFormat() + public function getDateFormat() { return 'l jS \of F Y h:i:s A'; }