Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit CCK download to make PHP acceptance tests run #135

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ target "php-test" {
context = "php"
target = "tested"
contexts = {
# replaces the stage that does `git clone` and ensures we get a fresh version
cck = "https://github.com/cucumber/compatibility-kit.git#main:devkit",
schema-codegen = "target:php-codegen",
}
}
Expand Down
10 changes: 10 additions & 0 deletions php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ WORKDIR /cucumber
FROM scratch AS schema-codegen


# Stage to download the CCK data, overridden in main build but included here in case building in the subfolder
# NB - when buildkit 1.5 is released this can be replaced with an ADD from the git URL
FROM bitnami/git AS cck
RUN git clone https://github.com/cucumber/compatibility-kit.git \
&& cd compatibility-kit \
&& git checkout main \
&& cp -R ./devkit/samples /samples


FROM php AS with-dependencies

COPY --link composer.json .
Expand All @@ -23,6 +32,7 @@ FROM php AS tested
COPY --link . .
COPY --link --from=with-dependencies /cucumber/vendor vendor
COPY --link --from=schema-codegen / src-generated
COPY --link --from=cck /samples/ ./tests/cck-samples
RUN vendor/bin/php-cs-fixer --dry-run --diff fix
RUN vendor/bin/psalm --no-cache
RUN vendor/bin/phpunit
3 changes: 2 additions & 1 deletion php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"Cucumber\\Messages\\": [
"src",
"src-generated",
"tests"
"tests",
"tests/unit"
]
}
}
Expand Down
7 changes: 5 additions & 2 deletions php/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
<testsuite name="unit">
<directory>tests/unit</directory>
</testsuite>
<testsuite name="end-to-end">
<file>tests/CckTest.php</file>
</testsuite>
</testsuites>

Expand Down
16 changes: 13 additions & 3 deletions php/tests/AcceptanceTest.php → php/tests/CckTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

use Cucumber\Messages\Envelope;
namespace Cucumber\Messages;

use Cucumber\Messages\Streams\NdJson\NdJsonStreamReader;
use Cucumber\Messages\Streams\NdJson\NdJsonStreamWriter;
use Exception;
use Generator;
use PHPUnit\Framework\TestCase;

class AcceptanceTest extends TestCase
class CckTest extends TestCase
{
/** @dataProvider provideJsonLines */
public function testAllNdJsonSurvivesDecodingThenEncoding(string $json): void
Expand Down Expand Up @@ -74,6 +77,13 @@ public function provideNdJsonFilenames(): Generator
*/
private function getSampleFiles(): array
{
return glob(__DIR__ . '/../../../node_modules/@cucumber/compatibility-kit/features/**/*.ndjson') ?: [];
$files = glob(pattern:__DIR__ . '/cck-samples/**/*.ndjson');

// glob doesn't error if dir is empty
if ($files === []) {
throw new Exception('CCK sample files not found. Perhaps you want to run the "unit" testsuite?');
}

return $files;
}
}
1 change: 1 addition & 0 deletions php/tests/cck-samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

use Cucumber\Messages\Envelope;
use Cucumber\Messages\Feature;
use Cucumber\Messages\GherkinDocument;
use Cucumber\Messages\Location;
namespace Cucumber\Messages;

use PHPUnit\Framework\TestCase;

class EnvelopeTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

namespace Cucumber\Messages;

use Cucumber\Messages\DecodingException\MalformedJsonException;
use Cucumber\Messages\JsonEncodingTrait;
use Cucumber\Messages\DecodingException\SchemaViolationException;
use Cucumber\Messages\DecodingException\UnexpectedDecodingException;
use JsonSerializable;
use PHPUnit\Framework\TestCase;
use RuntimeException;

class JsonDecodingTraitTest extends TestCase
{
Expand Down