Skip to content

Commit 38d1fe0

Browse files
committed
Avoid using helpers
Helpers are tested with a separate job
1 parent 7d8485f commit 38d1fe0

File tree

9 files changed

+79
-22
lines changed

9 files changed

+79
-22
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
phpunit:
99
name: phpunit
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
1313
php-version:
@@ -48,3 +48,32 @@ jobs:
4848
run: |
4949
composer global require php-coveralls/php-coveralls
5050
php-coveralls --coverage_clover=build/logs/clover.xml -v
51+
52+
test-helpers:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
- name: Install PHP
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
coverage: xdebug
61+
php-version: "7.1"
62+
ini-values: memory_limit=-1
63+
tools: composer:v2
64+
- name: Cache dependencies
65+
uses: actions/cache@v4
66+
with:
67+
path: |
68+
~/.composer/cache
69+
vendor
70+
key: "php-7.1"
71+
restore-keys: "php-7.1"
72+
73+
- name: Install dependencies
74+
run: composer install --no-interaction --no-progress
75+
76+
- name: Run PHPUnit
77+
run: make test
78+
env:
79+
PHPUNIT_VERSION: "07-helpers"

phpcs.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@
2727
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
2828
<exclude-pattern>*/lib/Inflections/*</exclude-pattern>
2929
</rule>
30+
31+
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
32+
<exclude-pattern>*/tests/HelpersTest.php</exclude-pattern>
33+
</rule>
3034
</ruleset>

phpunit07-helpers.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
executionOrder="depends,defects"
6+
beStrictAboutOutputDuringTests="true"
7+
verbose="true"
8+
colors="true"
9+
>
10+
<testsuites>
11+
<testsuite name="icanboogie/inflector">
12+
<file>tests/HelpersTest.php</file>
13+
</testsuite>
14+
</testsuites>
15+
16+
<filter>
17+
<whitelist>
18+
<directory suffix=".php">lib</directory>
19+
</whitelist>
20+
</filter>
21+
</phpunit>

phpunit07.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
4-
bootstrap="tests/bootstrap.php"
4+
bootstrap="vendor/autoload.php"
55
executionOrder="depends,defects"
66
beStrictAboutOutputDuringTests="true"
77
verbose="true"
88
colors="true"
99
>
1010
<testsuites>
1111
<testsuite name="icanboogie/inflector">
12-
<directory>./tests</directory>
12+
<directory>tests</directory>
13+
<exclude>tests/HelpersTest.php</exclude>
1314
</testsuite>
1415
</testsuites>
1516

1617
<filter>
1718
<whitelist>
18-
<directory suffix=".php">./lib</directory>
19+
<directory suffix=".php">lib</directory>
20+
<exclude>
21+
<file>lib/helpers.php</file>
22+
</exclude>
1923
</whitelist>
2024
</filter>
2125
</phpunit>

phpunit11.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
44
beStrictAboutCoverageMetadata="true"
55
beStrictAboutOutputDuringTests="true"
6-
bootstrap="tests/bootstrap.php"
6+
bootstrap="vendor/autoload.php"
77
colors="true"
88
displayDetailsOnTestsThatTriggerDeprecations="true"
99
displayDetailsOnTestsThatTriggerNotices="true"
@@ -14,11 +14,15 @@
1414
<testsuites>
1515
<testsuite name="icanboogie/inflector">
1616
<directory>tests</directory>
17+
<exclude>tests/HelpersTest.php</exclude>
1718
</testsuite>
1819
</testsuites>
1920
<source>
2021
<include>
2122
<directory>lib</directory>
2223
</include>
24+
<exclude>
25+
<file>lib/helpers.php</file>
26+
</exclude>
2327
</source>
2428
</phpunit>

tests/HelpersTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Tests\ICanBoogie;
44

5+
require_once __DIR__ . '/../lib/helpers.php';
6+
57
use PHPUnit\Framework\Attributes\DataProvider;
68
use PHPUnit\Framework\TestCase;
79

tests/InflectionsTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313

1414
use ICanBoogie\Inflections;
1515
use ICanBoogie\InflectionsNotFound;
16+
use ICanBoogie\StaticInflector;
1617
use PHPUnit\Framework\Attributes\DataProvider;
1718
use PHPUnit\Framework\Attributes\Group;
1819
use PHPUnit\Framework\TestCase;
1920

20-
use function ICanBoogie\pluralize;
21-
use function ICanBoogie\singularize;
22-
2321
/**
2422
* @group integration
2523
*/
@@ -39,7 +37,7 @@ public function test_fail_on_undefined_inflections(): void
3937
#[DataProvider('provide_singular_and_plural')]
4038
public function test_singular_to_plural(string $locale, string $singular, string $plural): void
4139
{
42-
$this->assertEquals($plural, pluralize($singular, $locale));
40+
$this->assertEquals($plural, StaticInflector::pluralize($singular, $locale));
4341
}
4442

4543
/**
@@ -48,7 +46,7 @@ public function test_singular_to_plural(string $locale, string $singular, string
4846
#[DataProvider('provide_singular_and_plural')]
4947
public function test_plural_to_singular(string $locale, string $singular, string $plural): void
5048
{
51-
$this->assertEquals($singular, singularize($plural, $locale));
49+
$this->assertEquals($singular, StaticInflector::singularize($plural, $locale));
5250
}
5351

5452
// @phpstan-ignore-next-line

tests/InflectorTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
use ICanBoogie\Inflections;
1515
use ICanBoogie\Inflector;
16+
use ICanBoogie\StaticInflector;
1617
use PHPUnit\Framework\TestCase;
1718

18-
use function ICanBoogie\camelize;
19-
2019
final class InflectorTest extends TestCase
2120
{
2221
/**
@@ -73,39 +72,39 @@ public function test_camelize(): void
7372

7473
foreach ($ar as $camel => $underscore) {
7574
$this->assertEquals($camel, self::$inflector->camelize($underscore));
76-
$this->assertEquals($camel, camelize($underscore));
75+
$this->assertEquals($camel, StaticInflector::camelize($underscore));
7776
}
7877

7978
$ar = require __DIR__ . '/cases/camel_to_dash.php';
8079

8180
foreach ($ar as $camel => $dash) {
8281
$this->assertEquals($camel, self::$inflector->camelize($dash));
83-
$this->assertEquals($camel, camelize($dash));
82+
$this->assertEquals($camel, StaticInflector::camelize($dash));
8483
}
8584
}
8685

8786
public function test_camelize_with_lower_upcases_the_first_letter(): void
8887
{
8988
$this->assertEquals('Capital', self::$inflector->camelize('capital'));
90-
$this->assertEquals('Capital', camelize('capital'));
89+
$this->assertEquals('Capital', StaticInflector::camelize('capital'));
9190
}
9291

9392
public function test_camelize_preserve_words_ends(): void
9493
{
9594
$this->assertEquals('WordOne\\WordTwo', self::$inflector->camelize('wordOne/wordTwo'));
96-
$this->assertEquals('WordOne\\WordTwo', camelize('wordOne/wordTwo'));
95+
$this->assertEquals('WordOne\\WordTwo', StaticInflector::camelize('wordOne/wordTwo'));
9796
}
9897

9998
public function test_camelize_with_lower_downcases_the_first_letter(): void
10099
{
101100
$this->assertEquals('capital', self::$inflector->camelize('Capital', true));
102-
$this->assertEquals('capital', camelize('Capital', true));
101+
$this->assertEquals('capital', StaticInflector::camelize('Capital', true));
103102
}
104103

105104
public function test_camelize_with_underscores(): void
106105
{
107106
$this->assertEquals("CamelCase", self::$inflector->camelize('Camel_Case'));
108-
$this->assertEquals("CamelCase", camelize('Camel_Case'));
107+
$this->assertEquals("CamelCase", StaticInflector::camelize('Camel_Case'));
109108
}
110109

111110
public function test_acronyms(): void

tests/bootstrap.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)