Skip to content

Avoid using helpers #45

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

Merged
merged 1 commit into from
May 26, 2025
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
31 changes: 30 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
phpunit:
name: phpunit
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
Expand Down Expand Up @@ -48,3 +48,32 @@ jobs:
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v

test-helpers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: "7.1"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.composer/cache
vendor
key: "php-7.1"
restore-keys: "php-7.1"

- name: Install dependencies
run: composer install --no-interaction --no-progress

- name: Run PHPUnit
run: make test
env:
PHPUNIT_VERSION: "07-helpers"
28 changes: 26 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
# CHANGELOG

## 2.x to 3.0
## v3.0.1

### New requirements

None

### New features

None

### Backward Incompatible Changes

None

### Deprecated Features

None

### Other Changes

Fix: Helpers are used, although they are no longer required by default. @donatj



## v3.0

### New requirements

Expand All @@ -26,7 +50,7 @@ None



## 1.x to 2.0
## v2.0

### New requirements

Expand Down
4 changes: 4 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<exclude-pattern>*/lib/Inflections/*</exclude-pattern>
</rule>

<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>*/tests/HelpersTest.php</exclude-pattern>
</rule>
</ruleset>
21 changes: 21 additions & 0 deletions phpunit07-helpers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
verbose="true"
colors="true"
>
<testsuites>
<testsuite name="icanboogie/inflector">
<file>tests/HelpersTest.php</file>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">lib</directory>
</whitelist>
</filter>
</phpunit>
10 changes: 7 additions & 3 deletions phpunit07.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
verbose="true"
colors="true"
>
<testsuites>
<testsuite name="icanboogie/inflector">
<directory>./tests</directory>
<directory>tests</directory>
<exclude>tests/HelpersTest.php</exclude>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./lib</directory>
<directory suffix=".php">lib</directory>
<exclude>
<file>lib/helpers.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>
6 changes: 5 additions & 1 deletion phpunit11.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
Expand All @@ -14,11 +14,15 @@
<testsuites>
<testsuite name="icanboogie/inflector">
<directory>tests</directory>
<exclude>tests/HelpersTest.php</exclude>
</testsuite>
</testsuites>
<source>
<include>
<directory>lib</directory>
</include>
<exclude>
<file>lib/helpers.php</file>
</exclude>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions tests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Tests\ICanBoogie;

require_once __DIR__ . '/../lib/helpers.php';

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

Expand Down
8 changes: 3 additions & 5 deletions tests/InflectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

use ICanBoogie\Inflections;
use ICanBoogie\InflectionsNotFound;
use ICanBoogie\StaticInflector;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

use function ICanBoogie\pluralize;
use function ICanBoogie\singularize;

/**
* @group integration
*/
Expand All @@ -39,7 +37,7 @@ public function test_fail_on_undefined_inflections(): void
#[DataProvider('provide_singular_and_plural')]
public function test_singular_to_plural(string $locale, string $singular, string $plural): void
{
$this->assertEquals($plural, pluralize($singular, $locale));
$this->assertEquals($plural, StaticInflector::pluralize($singular, $locale));
}

/**
Expand All @@ -48,7 +46,7 @@ public function test_singular_to_plural(string $locale, string $singular, string
#[DataProvider('provide_singular_and_plural')]
public function test_plural_to_singular(string $locale, string $singular, string $plural): void
{
$this->assertEquals($singular, singularize($plural, $locale));
$this->assertEquals($singular, StaticInflector::singularize($plural, $locale));
}

// @phpstan-ignore-next-line
Expand Down
15 changes: 7 additions & 8 deletions tests/InflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

use ICanBoogie\Inflections;
use ICanBoogie\Inflector;
use ICanBoogie\StaticInflector;
use PHPUnit\Framework\TestCase;

use function ICanBoogie\camelize;

final class InflectorTest extends TestCase
{
/**
Expand Down Expand Up @@ -73,39 +72,39 @@ public function test_camelize(): void

foreach ($ar as $camel => $underscore) {
$this->assertEquals($camel, self::$inflector->camelize($underscore));
$this->assertEquals($camel, camelize($underscore));
$this->assertEquals($camel, StaticInflector::camelize($underscore));
}

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

foreach ($ar as $camel => $dash) {
$this->assertEquals($camel, self::$inflector->camelize($dash));
$this->assertEquals($camel, camelize($dash));
$this->assertEquals($camel, StaticInflector::camelize($dash));
}
}

public function test_camelize_with_lower_upcases_the_first_letter(): void
{
$this->assertEquals('Capital', self::$inflector->camelize('capital'));
$this->assertEquals('Capital', camelize('capital'));
$this->assertEquals('Capital', StaticInflector::camelize('capital'));
}

public function test_camelize_preserve_words_ends(): void
{
$this->assertEquals('WordOne\\WordTwo', self::$inflector->camelize('wordOne/wordTwo'));
$this->assertEquals('WordOne\\WordTwo', camelize('wordOne/wordTwo'));
$this->assertEquals('WordOne\\WordTwo', StaticInflector::camelize('wordOne/wordTwo'));
}

public function test_camelize_with_lower_downcases_the_first_letter(): void
{
$this->assertEquals('capital', self::$inflector->camelize('Capital', true));
$this->assertEquals('capital', camelize('Capital', true));
$this->assertEquals('capital', StaticInflector::camelize('Capital', true));
}

public function test_camelize_with_underscores(): void
{
$this->assertEquals("CamelCase", self::$inflector->camelize('Camel_Case'));
$this->assertEquals("CamelCase", camelize('Camel_Case'));
$this->assertEquals("CamelCase", StaticInflector::camelize('Camel_Case'));
}

public function test_acronyms(): void
Expand Down
4 changes: 0 additions & 4 deletions tests/bootstrap.php

This file was deleted.