Skip to content

Commit

Permalink
migrate to phpunit attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor committed Nov 24, 2023
1 parent 481f4cc commit f0c56b7
Show file tree
Hide file tree
Showing 217 changed files with 697 additions and 1,435 deletions.
4 changes: 3 additions & 1 deletion dev/Compilers/TestCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Hoa\Compiler\Llk\TreeNode;
use Major\PluralRules\Dev\Helpers as H;
use Nette\PhpGenerator as Gen;
use PHPUnit\Framework\Attributes\DataProvider;
use Psl\Str;
use Psl\Vec;

Expand Down Expand Up @@ -66,6 +67,7 @@ private function compileTests(string $locale, string $name, array $samples): str

$namespace = $file->addNamespace('Major\\PluralRules\\Tests\\Locale')
->addUse(\Major\PluralRules\PluralRules::class)
->addUse(\PHPUnit\Framework\Attributes\DataProvider::class)
->addUse(\PHPUnit\Framework\TestCase::class);

$class = $namespace->addClass($name)
Expand Down Expand Up @@ -93,7 +95,7 @@ public function compileTest(
$providerName = H\camel('provide', $category, 'cases');

$test = $class->addMethod(H\camel('test', $category))
->addComment("@dataProvider {$providerName}")
->addAttribute(DataProvider::class, [$providerName])
->setReturnType('void')
->addBody('$category = PluralRules::select(?, $num);', [$locale])
->addBody('$this->assertSame(?, $category);', [$category]);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AfTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('af', $num);
Expand All @@ -30,9 +29,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('af', $num);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AkTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('ak', $num);
Expand All @@ -35,9 +34,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('ak', $num);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AmTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('am', $num);
Expand All @@ -31,9 +30,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('am', $num);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AnTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('an', $num);
Expand All @@ -30,9 +29,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('an', $num);
Expand Down
25 changes: 7 additions & 18 deletions tests/Locale/ArTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class ArTest extends TestCase
{
/**
* @dataProvider provideZeroCases
*/
#[DataProvider('provideZeroCases')]
public function testZero(int|float|string $num): void
{
$category = PluralRules::select('ar', $num);
Expand All @@ -30,9 +29,7 @@ public static function provideZeroCases(): array
];
}

/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('ar', $num);
Expand All @@ -53,9 +50,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideTwoCases
*/
#[DataProvider('provideTwoCases')]
public function testTwo(int|float|string $num): void
{
$category = PluralRules::select('ar', $num);
Expand All @@ -76,9 +71,7 @@ public static function provideTwoCases(): array
];
}

/**
* @dataProvider provideFewCases
*/
#[DataProvider('provideFewCases')]
public function testFew(int|float|string $num): void
{
$category = PluralRules::select('ar', $num);
Expand Down Expand Up @@ -109,9 +102,7 @@ public static function provideFewCases(): array
];
}

/**
* @dataProvider provideManyCases
*/
#[DataProvider('provideManyCases')]
public function testMany(int|float|string $num): void
{
$category = PluralRules::select('ar', $num);
Expand Down Expand Up @@ -141,9 +132,7 @@ public static function provideManyCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('ar', $num);
Expand Down
25 changes: 7 additions & 18 deletions tests/Locale/ArsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class ArsTest extends TestCase
{
/**
* @dataProvider provideZeroCases
*/
#[DataProvider('provideZeroCases')]
public function testZero(int|float|string $num): void
{
$category = PluralRules::select('ars', $num);
Expand All @@ -30,9 +29,7 @@ public static function provideZeroCases(): array
];
}

/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('ars', $num);
Expand All @@ -53,9 +50,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideTwoCases
*/
#[DataProvider('provideTwoCases')]
public function testTwo(int|float|string $num): void
{
$category = PluralRules::select('ars', $num);
Expand All @@ -76,9 +71,7 @@ public static function provideTwoCases(): array
];
}

/**
* @dataProvider provideFewCases
*/
#[DataProvider('provideFewCases')]
public function testFew(int|float|string $num): void
{
$category = PluralRules::select('ars', $num);
Expand Down Expand Up @@ -109,9 +102,7 @@ public static function provideFewCases(): array
];
}

/**
* @dataProvider provideManyCases
*/
#[DataProvider('provideManyCases')]
public function testMany(int|float|string $num): void
{
$category = PluralRules::select('ars', $num);
Expand Down Expand Up @@ -141,9 +132,7 @@ public static function provideManyCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('ars', $num);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AsTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('as', $num);
Expand All @@ -31,9 +30,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('as', $num);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AsaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AsaTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('asa', $num);
Expand All @@ -30,9 +29,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('asa', $num);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AstTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AstTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('ast', $num);
Expand All @@ -26,9 +25,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('ast', $num);
Expand Down
9 changes: 3 additions & 6 deletions tests/Locale/AzTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Major\PluralRules\Tests\Locale;

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

final class AzTest extends TestCase
{
/**
* @dataProvider provideOneCases
*/
#[DataProvider('provideOneCases')]
public function testOne(int|float|string $num): void
{
$category = PluralRules::select('az', $num);
Expand All @@ -30,9 +29,7 @@ public static function provideOneCases(): array
];
}

/**
* @dataProvider provideOtherCases
*/
#[DataProvider('provideOtherCases')]
public function testOther(int|float|string $num): void
{
$category = PluralRules::select('az', $num);
Expand Down
Loading

0 comments on commit f0c56b7

Please sign in to comment.