Skip to content
Merged
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: 1 addition & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e
with:
php-version: '8.3'
php-version: '8.4'
tools: composer

- name: Get Composer Cache Directory
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.3.10-cli-alpine3.20 AS build
FROM php:8.4.10-cli-alpine3.22 AS build

RUN apk add --no-cache ca-certificates curl jo zip unzip

Expand All @@ -9,7 +9,7 @@ RUN curl -L -o install-php-extensions \
&& chmod +x install-php-extensions \
&& install-php-extensions ds-^1@stable intl

COPY --from=composer:2.7.7 /usr/bin/composer /usr/local/bin/composer
COPY --from=composer:2.8.9 /usr/bin/composer /usr/local/bin/composer

WORKDIR /opt/test-runner
COPY . .
Expand All @@ -23,7 +23,7 @@ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
COMPOSER_ALLOW_SUPERUSER=1 \
composer install --no-cache --no-dev --no-interaction --no-progress

FROM php:8.3.10-cli-alpine3.20 AS runtime
FROM php:8.4.10-cli-alpine3.22 AS runtime

COPY --from=build /usr/bin/jo /usr/bin/jo
COPY --from=build /usr/local/lib/php/extensions /usr/local/lib/php/extensions
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It meets the complete spec for testing all exercises.
### Docker image

The website uses isolated Docker images to run untrusted code in a sandbox.
The image provided by this repository consists of PHP 8.3.10 (PHPUnit 10).
The image provided by this repository consists of PHP 8.4.10 (PHPUnit 11).
All final assets are built into the image, because the image does not have network access once in use.

Includes PHP extensions: ds, intl
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
}
},
"require": {
"php": "^8.3",
"phpunit/phpunit": "^10.5.29"
"php": "^8.4",
"phpunit/phpunit": "^11.5.26"
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"slevomat/coding-standard": "^8.14.1",
"squizlabs/php_codesniffer": "^3.12"
"phpstan/phpstan": "^2.1.17",
"slevomat/coding-standard": "^8.19.1",
"squizlabs/php_codesniffer": "^3.13.2"
},
"scripts": {
"phpstan": "phpstan analyse --configuration phpstan.neon --memory-limit=2G",
Expand Down
6 changes: 6 additions & 0 deletions tests/all-fail/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
return "Goodbye, Mars!";
}
26 changes: 26 additions & 0 deletions tests/all-fail/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

public function testHelloWorldOne(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}

public function testHelloWorldTwo(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}

public function testHelloWorldThree(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}
}
1 change: 1 addition & 0 deletions tests/all-fail/expected_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"fail","tests":[{"name":"Hello world one","status":"fail","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n","message":"HelloWorldTest::testHelloWorldOne\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Hello, World!'\n+'Goodbye, Mars!'\n\nHelloWorldTest.php:14"},{"name":"Hello world two","status":"fail","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n","message":"HelloWorldTest::testHelloWorldTwo\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Hello, World!'\n+'Goodbye, Mars!'\n\nHelloWorldTest.php:19"},{"name":"Hello world three","status":"fail","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n","message":"HelloWorldTest::testHelloWorldThree\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Hello, World!'\n+'Goodbye, Mars!'\n\nHelloWorldTest.php:24"}]}
4 changes: 2 additions & 2 deletions tests/dataProvider-error/GigasecondTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function dateSetup($date): DateTimeImmutable
return new DateTimeImmutable($date, $UTC);
}

public function inputAndExpectedDates(): array
public static function inputAndExpectedDates(): array
{
return [
['2011-04-25', '2043-01-01 01:46:40'],
Expand All @@ -48,7 +48,7 @@ public function inputAndExpectedDates(): array
];
}

public function inputDates(): array
public static function inputDates(): array
{
return [
['2011-04-25'],
Expand Down
6 changes: 6 additions & 0 deletions tests/error-with-task-id/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
throw new \BadFunctionCallException("Implement the helloWorld() function");
}
17 changes: 17 additions & 0 deletions tests/error-with-task-id/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

/** @task_id 99 */
public function testHelloWorld(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}
}
1 change: 1 addition & 0 deletions tests/error-with-task-id/expected_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"fail","tests":[{"name":"Hello world","status":"error","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n","task_id":99,"message":"HelloWorldTest::testHelloWorld\nBadFunctionCallException: Implement the helloWorld() function\n\nHelloWorld.php:5\nHelloWorldTest.php:15"}]}
6 changes: 6 additions & 0 deletions tests/fail-with-array/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
return ["Goodbye, Mars!"];
}
16 changes: 16 additions & 0 deletions tests/fail-with-array/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

public function testHelloWorld(): void
{
$this->assertEquals(['Hello, World!'], helloWorld());
}
}
1 change: 1 addition & 0 deletions tests/fail-with-array/expected_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"fail","tests":[{"name":"Hello world","status":"fail","test_code":"$this->assertEquals(['Hello, World!'], helloWorld());\n","message":"HelloWorldTest::testHelloWorld\nFailed asserting that two arrays are equal.\n--- Expected\n+++ Actual\n@@ @@\n Array (\n- 0 => 'Hello, World!'\n+ 0 => 'Goodbye, Mars!'\n )\n\nHelloWorldTest.php:14"}]}
6 changes: 6 additions & 0 deletions tests/fail-with-task-id/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
return "Goodbye, Mars!";
}
17 changes: 17 additions & 0 deletions tests/fail-with-task-id/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

/** @task_id 99 */
public function testHelloWorld(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}
}
1 change: 1 addition & 0 deletions tests/fail-with-task-id/expected_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"fail","tests":[{"name":"Hello world","status":"fail","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n","task_id":99,"message":"HelloWorldTest::testHelloWorld\nFailed asserting that two strings are equal.\n--- Expected\n+++ Actual\n@@ @@\n-'Hello, World!'\n+'Goodbye, Mars!'\n\nHelloWorldTest.php:15"}]}
6 changes: 6 additions & 0 deletions tests/success-with-testdox-and-task-id/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
return "Hello, World!";
}
20 changes: 20 additions & 0 deletions tests/success-with-testdox-and-task-id/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\Attributes\TestDox;

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

/** @task_id 99 */
#[TestDox('"Hello, World!" from TestDox attribute')]
public function testNameDoesNotMatter(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"pass","tests":[{"name":"\"Hello, World!\" from TestDox attribute","status":"pass","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n","task_id":99}]}
6 changes: 6 additions & 0 deletions tests/success-with-testdox-and-uuid/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
return "Hello, World!";
}
20 changes: 20 additions & 0 deletions tests/success-with-testdox-and-uuid/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\Attributes\TestDox;

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

/** uuid: af9ffe10-dc13-42d8-a742-e7bdafac449d */
#[TestDox('"Hello, World!" from TestDox attribute')]
public function testNameDoesNotMatter(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"pass","tests":[{"name":"\"Hello, World!\" from TestDox attribute","status":"pass","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n"}]}
6 changes: 6 additions & 0 deletions tests/success-with-testdox-uuid-and-task-id/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
return "Hello, World!";
}
23 changes: 23 additions & 0 deletions tests/success-with-testdox-uuid-and-task-id/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\Attributes\TestDox;

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

/**
* uuid: af9ffe10-dc13-42d8-a742-e7bdafac449d
* @task_id 99
*/
#[TestDox('"Hello, World!" from TestDox attribute')]
public function testNameDoesNotMatter(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"pass","tests":[{"name":"\"Hello, World!\" from TestDox attribute","status":"pass","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n","task_id":99}]}
6 changes: 6 additions & 0 deletions tests/success-with-testdox/HelloWorld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function helloWorld()
{
return "Hello, World!";
}
19 changes: 19 additions & 0 deletions tests/success-with-testdox/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\Attributes\TestDox;

class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
{
require_once 'HelloWorld.php';
}

#[TestDox('"Hello, World!" from TestDox attribute')]
public function testNameDoesNotMatter(): void
{
$this->assertEquals('Hello, World!', helloWorld());
}
}
1 change: 1 addition & 0 deletions tests/success-with-testdox/expected_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"status":"pass","tests":[{"name":"\"Hello, World!\" from TestDox attribute","status":"pass","test_code":"$this->assertEquals('Hello, World!', helloWorld());\n"}]}