Skip to content

Commit 228b8a3

Browse files
committed
Improve test setup
After the latest changes, we were not running the integration tests because we were not including PHPT files in the test suite. This commit will also make a few other improvements. Signed-off-by: Henrique Moody <[email protected]>
1 parent e88515f commit 228b8a3

16 files changed

+68
-83
lines changed

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@
2525
},
2626
"autoload": {
2727
"psr-4": {
28-
"Respect\\Stringifier\\": "src/",
28+
"Respect\\Stringifier\\": "src/"
29+
},
30+
"files": [
31+
"src/stringify.php"
32+
]
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
2936
"Respect\\Stringifier\\Test\\": "tests/src/",
3037
"Respect\\Stringifier\\Test\\Unit\\": "tests/unit"
3138
},
3239
"files": [
33-
"src/stringify.php"
40+
"tests/integration/lib/helpers.php"
3441
]
3542
},
3643
"scripts": {

phpunit.xml.dist

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version="1.0"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
bootstrap="vendor/autoload.php"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
54
cacheDirectory=".phpunit.cache">
6-
<coverage>
7-
<include>
8-
<directory>src/</directory>
9-
</include>
10-
</coverage>
5+
<coverage/>
116
<testsuites>
127
<testsuite name="integration">
13-
<directory suffix="Test.php">tests/integration/</directory>
8+
<directory suffix=".phpt">tests/integration/</directory>
149
</testsuite>
1510
<testsuite name="unit">
16-
<directory suffix="Test.php">tests/unit/</directory>
11+
<directory>tests/unit/</directory>
1712
</testsuite>
1813
</testsuites>
14+
<source>
15+
<include>
16+
<directory>src/</directory>
17+
</include>
18+
</source>
1919
</phpunit>

tests/integration/lib/helpers.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Respect/Stringifier.
5+
* Copyright (c) Henrique Moody <[email protected]>
6+
* SPDX-License-Identifier: MIT
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
use function Respect\Stringifier\stringify;
12+
13+
function output(mixed $value): void
14+
{
15+
echo stringify($value) . PHP_EOL;
16+
}
17+
18+
function outputMultiple(mixed ...$values): void
19+
{
20+
foreach ($values as $value) {
21+
output($value);
22+
}
23+
}

tests/integration/stringify-array.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ declare(strict_types=1);
55

66
require 'vendor/autoload.php';
77

8-
use function Respect\Stringifier\stringify;
9-
10-
echo stringify([
8+
output([
119
1,
1210
null,
1311
[

tests/integration/stringify-bool.phpt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@ declare(strict_types=1);
55

66
require 'vendor/autoload.php';
77

8-
use function Respect\Stringifier\stringify;
9-
10-
echo implode(
11-
PHP_EOL,
12-
[
13-
stringify(true),
14-
stringify(false),
15-
]
8+
outputMultiple(
9+
true,
10+
false,
1611
);
1712
?>
1813
--EXPECT--

tests/integration/stringify-float.phpt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@ declare(strict_types=1);
55

66
require 'vendor/autoload.php';
77

8-
use function Respect\Stringifier\stringify;
9-
10-
echo implode(
11-
PHP_EOL,
12-
[
13-
stringify(1.0),
14-
stringify(.3),
15-
stringify(INF),
16-
stringify(-1 * INF),
17-
stringify(acos(8)),
18-
]
8+
outputMultiple(
9+
1.0,
10+
.3,
11+
INF,
12+
-1 * INF,
13+
acos(8),
1914
);
2015
?>
2116
--EXPECT--

tests/integration/stringify-int.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ declare(strict_types=1);
55

66
require 'vendor/autoload.php';
77

8-
use function Respect\Stringifier\stringify;
9-
10-
echo stringify(1);
8+
output(1);
119
?>
1210
--EXPECT--
1311
1

tests/integration/stringify-null.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ declare(strict_types=1);
55

66
require 'vendor/autoload.php';
77

8-
use function Respect\Stringifier\stringify;
9-
10-
echo stringify(null);
8+
output(null);
119
?>
1210
--EXPECT--
1311
`NULL`

tests/integration/stringify-object-dateTime.phpt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,9 @@ declare(strict_types=1);
55

66
require 'vendor/autoload.php';
77

8-
use function Respect\Stringifier\stringify;
9-
10-
$dateTime = new DateTime('2017-12-31T23:59:59+00:00');
11-
$dateTimeImmutable = DateTimeImmutable::createFromMutable($dateTime);
12-
13-
echo implode(
14-
PHP_EOL,
15-
[
16-
stringify($dateTime),
17-
stringify($dateTimeImmutable),
18-
]
8+
outputMultiple(
9+
new DateTime('2017-12-31T23:59:59+00:00'),
10+
new DateTimeImmutable('2017-12-31T23:59:59+00:00'),
1911
);
2012
?>
2113
--EXPECT--

tests/integration/stringify-object-jsonSerializable.phpt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ declare(strict_types=1);
55

66
require 'vendor/autoload.php';
77

8-
use Respect\Stringifier\Test\MyJsonSerializable;
9-
use function Respect\Stringifier\stringify;
10-
11-
echo stringify(new MyJsonSerializable());
8+
output(new Respect\Stringifier\Test\MyJsonSerializable());
129
?>
1310
--EXPECT--
1411
`[json-serializable] (Respect\Stringifier\Test\MyJsonSerializable: { 1, 2, 3 })`

0 commit comments

Comments
 (0)