diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 7df1798..fe9e029 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -29,7 +29,7 @@ jobs: extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite ini-values: opcache.fast_shutdown=0 - - name: "[1/4] Create composer project - Cache composer dependencies" + - name: "[1/5] Create composer project - Cache composer dependencies" uses: actions/cache@v1 with: path: ~/.composer/cache @@ -37,14 +37,18 @@ jobs: restore-keys: | php-${{ matrix.php-version }}-flow-${{ matrix.flow-version }}-composer- php-${{ matrix.php-version }}-flow- - - name: "[2/4] Create composer project - No install" + - name: "[2/5] Create composer project - No install" run: composer create-project neos/flow-base-distribution ${{ env.FLOW_DIST_FOLDER }} --prefer-dist --no-progress --no-install "^${{ matrix.flow-version }}" - - name: "[3/4] Create composer project - Require behat in compatible version" + - name: "[3/5] Allow neos composer plugin" + run: composer config --no-plugins allow-plugins.neos/composer-plugin true + working-directory: ${{ env.FLOW_DIST_FOLDER }} + + - name: "[4/5] Create composer project - Require behat in compatible version" run: composer require --dev --no-update "neos/behat:@dev" working-directory: ${{ env.FLOW_DIST_FOLDER }} - - name: "[4/4] Create composer project - Install project" + - name: "[5/5] Create composer project - Install project" run: composer install working-directory: ${{ env.FLOW_DIST_FOLDER }} diff --git a/Tests/Unit/Domain/Service/ArrayQueryResult.php b/Tests/Unit/Domain/Service/ArrayQueryResult.php new file mode 100644 index 0000000..93b5726 --- /dev/null +++ b/Tests/Unit/Domain/Service/ArrayQueryResult.php @@ -0,0 +1,90 @@ +result = $result; + $this->iterator = (new ArrayObject($result))->getIterator(); + } + + public function current() + { + return $this->iterator->current(); + } + + public function next() + { + $this->iterator->next(); + } + + public function key() + { + return $this->iterator->key(); + } + + public function valid() + { + return $this->iterator->valid(); + } + + public function rewind() + { + $this->iterator->rewind(); + } + + public function offsetExists($offset) + { + return $this->iterator->offsetExists($offset); + } + + public function offsetGet($offset) + { + return $this->iterator->offsetGet($offset); + } + + public function offsetSet($offset, $value) + { + $this->iterator->offsetSet($offset, $value); + } + + public function offsetUnset($offset) + { + $this->iterator->offsetUnset($offset); + } + + public function count() + { + return $this->iterator->count(); + } + + public function getQuery(): QueryInterface + { + return new Query('foo'); + } + + public function getFirst() + { + reset($this->result); + + return current($this->result); + } + + public function toArray(): array + { + return $this->result; + } + +} diff --git a/Tests/Unit/Domain/Service/MigrationServiceTest.php b/Tests/Unit/Domain/Service/MigrationServiceTest.php index 396c290..1d72228 100644 --- a/Tests/Unit/Domain/Service/MigrationServiceTest.php +++ b/Tests/Unit/Domain/Service/MigrationServiceTest.php @@ -86,7 +86,7 @@ public function Can_Return_UnexecutedMigrations(): void ->willReturn($migrationMock); $this->migrationStatusRepository->method('findAll') - ->willReturn([]); + ->willReturn(new ArrayQueryResult([])); $this->assertCount(2, $this->migrationService->findUnexecutedMigrations()); } @@ -110,7 +110,7 @@ public function Can_Filter_Executed_Migrations_In_Get_UnexecutedMigrations(): vo ->willReturn('20191001142901'); $this->migrationStatusRepository->method('findAll') - ->willReturn([$migrationStatusMock]); + ->willReturn(new ArrayQueryResult([$migrationStatusMock])); $migrations = $this->migrationService->findUnexecutedMigrations(); @@ -137,7 +137,7 @@ public function Can_Return_A_Single_Migration(): void ->willReturn('20191001142901'); $this->migrationStatusRepository->method('findAll') - ->willReturn([$migrationStatusMock]); + ->willReturn(new ArrayQueryResult([$migrationStatusMock])); $migration = $this->migrationService->getMigrationByVersion('20191001142901'); @@ -165,7 +165,7 @@ public function Will_Throw_Unknown_Migration_If_Migration_Not_Found(): void ->willReturn('20191001142901'); $this->migrationStatusRepository->method('findAll') - ->willReturn([$migrationStatusMock]); + ->willReturn(new ArrayQueryResult([$migrationStatusMock])); $this->migrationService->getMigrationByVersion('1458'); } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aae4c4f..c576f5c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,26 +1,29 @@ - + + + + ./Classes + + + + + + + - + ./Tests/Unit/ - - - ./Classes - - - - - - +