From cd8d0288128b447ec9e32e5fa5cb741290019bfd Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Tue, 5 Mar 2019 18:11:31 +0300 Subject: [PATCH 1/9] =?UTF-8?q?=C2=A0=C2=A0Update=20Dockerfile,=20add=20fo?= =?UTF-8?q?r=20methods=20setUp=20and=20tearDown=20return=20type=20hint=20i?= =?UTF-8?q?n=20all=20tests,=20replace=20fire=20on=20dispatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 + Dockerfile | 36 ++++++++++++-------- composer.json | 3 ++ docker-compose.yml | 2 +- tests/AuthTest.php | 3 +- tests/EmbeddedRelationsTest.php | 58 ++++++++++++++++----------------- tests/GeospatialTest.php | 4 +-- tests/HybridRelationsTest.php | 4 +-- tests/ModelTest.php | 9 +++-- tests/QueryBuilderTest.php | 2 +- tests/QueryTest.php | 4 +-- tests/QueueTest.php | 2 +- tests/RelationsTest.php | 2 +- tests/SchemaTest.php | 2 +- tests/SeederTest.php | 2 +- tests/ValidationTest.php | 2 +- 16 files changed, 75 insertions(+), 61 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe11b61da..218c6ab1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ language: php php: - "7.2" - "7.1" + - "7.3" services: - docker diff --git a/Dockerfile b/Dockerfile index 68eac169d..3750e8f86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,27 @@ +ARG COMPOSER_VERSION=1.8 ARG PHP_VERSION=7.2 +FROM composer +FROM php:${PHP_VERSION}-cli-alpine -FROM php:${PHP_VERSION}-cli +RUN apk add --update --no-cache -t .php-build-deps \ + autoconf \ + libmcrypt=2.5.8-r7 \ + git \ + make \ + g++ \ + gcc \ + openssl-dev \ + libzip-dev; \ + pecl install mongodb-1.5.3 -RUN pecl install xdebug +RUN set -xe; \ + if [[ "${PHP_VERSION:0:3}" != "7.3" ]]; then \ + pecl install xdebug-2.6.1; \ + docker-php-ext-enable xdebug; \ + fi; + +RUN docker-php-ext-enable mongodb && \ + docker-php-ext-install -j$(nproc) pdo pdo_mysql zip -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 - -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}" +COPY --from=composer /usr/bin/composer /usr/local/bin/composer +RUN composer global require "hirak/prestissimo:^0.3" diff --git a/composer.json b/composer.json index e0da76b94..d9547ce4b 100644 --- a/composer.json +++ b/composer.json @@ -47,5 +47,8 @@ "Jenssegers\\Mongodb\\MongodbQueueServiceProvider" ] } + }, + "scripts": { + "run-tests": "vendor/bin/phpunit" } } diff --git a/docker-compose.yml b/docker-compose.yml index 42546660b..cbbaf14a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: volumes: - .:/code working_dir: /code - command: bash -c "composer install --prefer-source --no-interaction && php ./vendor/bin/phpunit" + command: sh -c "composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable && composer run-tests" depends_on: - mysql - mongodb diff --git a/tests/AuthTest.php b/tests/AuthTest.php index 2b671fdd5..e81efed90 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -5,8 +5,9 @@ class AuthTest extends TestCase { - public function tearDown() + public function tearDown(): void { + parent::setUp(); User::truncate(); DB::collection('password_reminders')->truncate(); } diff --git a/tests/EmbeddedRelationsTest.php b/tests/EmbeddedRelationsTest.php index 5caae5b28..440761e78 100644 --- a/tests/EmbeddedRelationsTest.php +++ b/tests/EmbeddedRelationsTest.php @@ -2,7 +2,7 @@ class EmbeddedRelationsTest extends TestCase { - public function tearDown() + public function tearDown(): void { Mockery::close(); @@ -21,11 +21,11 @@ public function testEmbedsManySave() $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 @@ public function testEmbedsManySave() $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 @@ public function testEmbedsManySave() // $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 @@ public function testEmbedsManyDestroy() $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 @@ public function testEmbedsManyDelete() $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 @@ public function testEmbedsManyCreatingEventReturnsFalse() $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 @@ public function testEmbedsManySavingEventReturnsFalse() $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 @@ public function testEmbedsManyUpdatingEventReturnsFalse() $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 @@ public function testEmbedsManyDeletingEventReturnsFalse() $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 @@ public function testEmbedsOne() $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 @@ public function testEmbedsOne() $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 @@ public function testEmbedsOne() $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 @@ public function testEmbedsOneAssociate() $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); diff --git a/tests/GeospatialTest.php b/tests/GeospatialTest.php index 2d646b337..b13ed46af 100644 --- a/tests/GeospatialTest.php +++ b/tests/GeospatialTest.php @@ -2,7 +2,7 @@ class GeospatialTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); @@ -43,7 +43,7 @@ public function setUp() ]); } - public function tearDown() + public function tearDown(): void { Schema::drop('locations'); } diff --git a/tests/HybridRelationsTest.php b/tests/HybridRelationsTest.php index 2223950ec..ade509067 100644 --- a/tests/HybridRelationsTest.php +++ b/tests/HybridRelationsTest.php @@ -2,7 +2,7 @@ class HybridRelationsTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); @@ -11,7 +11,7 @@ public function setUp() MysqlRole::executeSchema(); } - public function tearDown() + public function tearDown(): void { MysqlUser::truncate(); MysqlBook::truncate(); diff --git a/tests/ModelTest.php b/tests/ModelTest.php index 4387d1231..c95d189ed 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -8,7 +8,7 @@ class ModelTest extends TestCase { - public function tearDown() + public function tearDown(): void { User::truncate(); Soft::truncate(); @@ -261,10 +261,9 @@ public function testTouch() $user->age = 35; $user->save(); - $old = $user->updated_at; - - sleep(1); - $user->touch(); + $old = clone $user->updated_at; + sleep(2); + $res = $user->touch(); $check = User::find($user->_id); $this->assertNotEquals($old, $check->updated_at); diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index ac1479d26..0807b4ece 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -5,7 +5,7 @@ class QueryBuilderTest extends TestCase { - public function tearDown() + public function tearDown(): void { DB::collection('users')->truncate(); DB::collection('items')->truncate(); diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 2011305c2..de8589ebd 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -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 @@ public function setUp() User::create(['name' => 'Error', 'age' => null, 'title' => null]); } - public function tearDown() + public function tearDown(): void { User::truncate(); parent::tearDown(); diff --git a/tests/QueueTest.php b/tests/QueueTest.php index 35be33f9a..f3ebc94f6 100644 --- a/tests/QueueTest.php +++ b/tests/QueueTest.php @@ -2,7 +2,7 @@ class QueueTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/RelationsTest.php b/tests/RelationsTest.php index 1e2aaa491..de3e0f222 100644 --- a/tests/RelationsTest.php +++ b/tests/RelationsTest.php @@ -2,7 +2,7 @@ class RelationsTest extends TestCase { - public function tearDown() + public function tearDown(): void { Mockery::close(); diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index a04715d9d..5d63e28eb 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -2,7 +2,7 @@ class SchemaTest extends TestCase { - public function tearDown() + public function tearDown(): void { Schema::drop('newcollection'); } diff --git a/tests/SeederTest.php b/tests/SeederTest.php index 9581df3d3..61143e330 100644 --- a/tests/SeederTest.php +++ b/tests/SeederTest.php @@ -2,7 +2,7 @@ class SeederTest extends TestCase { - public function tearDown() + public function tearDown(): void { User::truncate(); } diff --git a/tests/ValidationTest.php b/tests/ValidationTest.php index 16e31f4cf..267996420 100644 --- a/tests/ValidationTest.php +++ b/tests/ValidationTest.php @@ -2,7 +2,7 @@ class ValidationTest extends TestCase { - public function tearDown() + public function tearDown(): void { User::truncate(); } From 178ce3bebf4643099085458ac87843c1396084ae Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Tue, 5 Mar 2019 23:07:58 +0300 Subject: [PATCH 2/9] Resolve error test with touch --- src/Jenssegers/Mongodb/Eloquent/Builder.php | 25 +++++++++++++++++++++ tests/ModelTest.php | 6 ++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Jenssegers/Mongodb/Eloquent/Builder.php b/src/Jenssegers/Mongodb/Eloquent/Builder.php index 1ee1c41fe..b14053229 100644 --- a/src/Jenssegers/Mongodb/Eloquent/Builder.php +++ b/src/Jenssegers/Mongodb/Eloquent/Builder.php @@ -177,6 +177,31 @@ public function raw($expression = null) 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 */ diff --git a/tests/ModelTest.php b/tests/ModelTest.php index c95d189ed..f6e4f4eb6 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -261,9 +261,9 @@ public function testTouch() $user->age = 35; $user->save(); - $old = clone $user->updated_at; - sleep(2); - $res = $user->touch(); + $old = $user->updated_at; + sleep(1); + $user->touch(); $check = User::find($user->_id); $this->assertNotEquals($old, $check->updated_at); From 01e599a3bf66bbc618d857a7390dc99d953513f9 Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Wed, 6 Mar 2019 08:32:30 +0300 Subject: [PATCH 3/9] Use COMPOSER_VERSION in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3750e8f86..ebdd39239 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG COMPOSER_VERSION=1.8 ARG PHP_VERSION=7.2 -FROM composer +FROM composer:${COMPOSER_VERSION} FROM php:${PHP_VERSION}-cli-alpine RUN apk add --update --no-cache -t .php-build-deps \ From 4c0f3fc871c1d50bb86d5b2c095b83abb3cdfb1c Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Wed, 6 Mar 2019 08:40:16 +0300 Subject: [PATCH 4/9] Add alias for composer --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ebdd39239..83730ab44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG COMPOSER_VERSION=1.8 ARG PHP_VERSION=7.2 -FROM composer:${COMPOSER_VERSION} +FROM composer:${COMPOSER_VERSION} as composer-build FROM php:${PHP_VERSION}-cli-alpine RUN apk add --update --no-cache -t .php-build-deps \ @@ -23,5 +23,5 @@ RUN set -xe; \ RUN docker-php-ext-enable mongodb && \ docker-php-ext-install -j$(nproc) pdo pdo_mysql zip -COPY --from=composer /usr/bin/composer /usr/local/bin/composer +COPY --from=composer-build /usr/bin/composer /usr/local/bin/composer RUN composer global require "hirak/prestissimo:^0.3" From b52c98f5b8079ecdbe8fd35fc5ac4efee5b18859 Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Thu, 7 Mar 2019 16:33:12 +0300 Subject: [PATCH 5/9] Change parent method's names Broken commit in laravel: https://github.com/laravel/framework/commit/2ee18923eaff142a89439f0adf0d3f15c30db85b --- src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php b/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php index 5fe908208..766567627 100644 --- a/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php +++ b/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php @@ -110,7 +110,7 @@ protected function getRelatedConstraintKey($relation) } if ($relation instanceof BelongsTo) { - return $relation->getForeignKey(); + return $relation->getForeignKeyName(); } if ($relation instanceof BelongsToMany && ! $this->isAcrossConnections($relation)) { @@ -130,7 +130,7 @@ protected function getHasCompareKey($relation) return $relation->getHasCompareKey(); } - return $relation instanceof HasOneOrMany ? $relation->getForeignKeyName() : $relation->getOwnerKey(); + return $relation instanceof HasOneOrMany ? $relation->getForeignKeyName() : $relation->getOwnerKeyName(); } /** From 281fdd245ecadb3d2b0e7e80062490db2e3329fa Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Sun, 10 Mar 2019 22:08:44 +0300 Subject: [PATCH 6/9] Remove changes in .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 218c6ab1e..fe11b61da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ language: php php: - "7.2" - "7.1" - - "7.3" services: - docker From 8c8de06c28739899b6fe31adec533076e5194284 Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Sun, 10 Mar 2019 22:54:40 +0300 Subject: [PATCH 7/9] Remove changes from Dockerfile --- Dockerfile | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83730ab44..af4cd61dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,17 @@ -ARG COMPOSER_VERSION=1.8 ARG PHP_VERSION=7.2 -FROM composer:${COMPOSER_VERSION} as composer-build -FROM php:${PHP_VERSION}-cli-alpine -RUN apk add --update --no-cache -t .php-build-deps \ - autoconf \ - libmcrypt=2.5.8-r7 \ - git \ - make \ - g++ \ - gcc \ - openssl-dev \ - libzip-dev; \ - pecl install mongodb-1.5.3 +FROM php:${PHP_VERSION}-cli -RUN set -xe; \ - if [[ "${PHP_VERSION:0:3}" != "7.3" ]]; then \ - pecl install xdebug-2.6.1; \ - docker-php-ext-enable xdebug; \ - fi; - -RUN docker-php-ext-enable mongodb && \ - docker-php-ext-install -j$(nproc) pdo pdo_mysql zip +RUN pecl install xdebug -COPY --from=composer-build /usr/bin/composer /usr/local/bin/composer -RUN composer global require "hirak/prestissimo:^0.3" +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 + +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 From 0ac68030a4e44762fe12966ba345d92243d692b7 Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Tue, 12 Mar 2019 08:27:39 +0300 Subject: [PATCH 8/9] Revert changes in docker-compose.yml --- Dockerfile | 2 +- composer.json | 3 --- docker-compose.yml | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index af4cd61dc..68eac169d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,4 @@ 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 +ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" diff --git a/composer.json b/composer.json index d9547ce4b..e0da76b94 100644 --- a/composer.json +++ b/composer.json @@ -47,8 +47,5 @@ "Jenssegers\\Mongodb\\MongodbQueueServiceProvider" ] } - }, - "scripts": { - "run-tests": "vendor/bin/phpunit" } } diff --git a/docker-compose.yml b/docker-compose.yml index cbbaf14a8..42546660b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: volumes: - .:/code working_dir: /code - command: sh -c "composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable && composer run-tests" + command: bash -c "composer install --prefer-source --no-interaction && php ./vendor/bin/phpunit" depends_on: - mysql - mongodb From 23fa853290e97bc04aa51e2f13537a1cba247a16 Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Tue, 12 Mar 2019 08:35:44 +0300 Subject: [PATCH 9/9] Update image with mysql --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 42546660b..a6e521d3b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: mysql: container_name: mysql - image: mysql + image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: MYSQL_DATABASE: unittest