Skip to content

Commit

Permalink
Merge pull request #12 from netlogix/bugfix/failing-builds
Browse files Browse the repository at this point in the history
  • Loading branch information
paxuclus authored Jul 6, 2022
2 parents e7c6fe7 + 2c0ff69 commit 8bf64af
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 25 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,26 @@ 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
key: php-${{ matrix.php-version }}-flow-${{ matrix.flow-version }}-composer-${{ hashFiles('composer.json') }}
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 }}

Expand Down
90 changes: 90 additions & 0 deletions Tests/Unit/Domain/Service/ArrayQueryResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
declare(strict_types=1);

namespace Netlogix\Migrations\Tests\Unit\Domain\Service;

use ArrayObject;
use Neos\Flow\Persistence\Doctrine\Query;
use Neos\Flow\Persistence\QueryInterface;
use Neos\Flow\Persistence\QueryResultInterface;

class ArrayQueryResult implements QueryResultInterface
{

private $result;
private $iterator;

public function __construct(array $result)
{
$this->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;
}

}
8 changes: 4 additions & 4 deletions Tests/Unit/Domain/Service/MigrationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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();

Expand All @@ -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');

Expand Down Expand Up @@ -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');
}
Expand Down
37 changes: 20 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
<?xml version="1.0"?>
<phpunit
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
timeoutForSmallTests="0">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
timeoutForSmallTests="0"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./Classes</directory>
</include>
<report>
<clover outputFile="Build/Artifacts/Reports/PhpUnit/clover.xml"/>
<crap4j outputFile="Build/Artifacts/Reports/PhpUnit/crap4j.xml"/>
<html outputDirectory="Build/Artifacts/Reports/PhpUnit/Coverage"/>
</report>
</coverage>
<testsuites>
<testsuite name="netlogix/migrations Unit Test">
<testsuite name="Unit">
<directory>./Tests/Unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./Classes</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="Build/Artifacts/Reports/PhpUnit/Coverage"/>
<log type="coverage-clover" target="Build/Artifacts/Reports/PhpUnit/clover.xml"/>
<log type="coverage-crap4j" target="Build/Artifacts/Reports/PhpUnit/crap4j.xml"/>
<log type="junit" target="Build/Artifacts/Reports/PhpUnit/junit.xml"/>
<junit outputFile="Build/Artifacts/Reports/PhpUnit/junit.xml"/>
</logging>
<php>
<ini name="date.timezone" value="Europe/Berlin"/>
Expand Down

0 comments on commit 8bf64af

Please sign in to comment.