Skip to content

Commit b31562d

Browse files
authored
Merge pull request #14 from franzose/fix/tests
fix: fix broken tests
2 parents 11687fd + e8d24e0 commit b31562d

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: 'Continuous Integration'
22

33
on:
44
pull_request: ~
5-
push:
6-
branches: [ 2.x ]
5+
push: ~
76

87
jobs:
98
unit-tests:

tests/Data/DataTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Kontrolio\Data\Attribute;
77
use Kontrolio\Data\Data;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89
use PHPUnit\Framework\TestCase;
910

1011
final class DataTest extends TestCase
@@ -15,6 +16,7 @@ final class DataTest extends TestCase
1516
* @param string|null $name
1617
* @param Attribute $expectedAttribute
1718
*/
19+
#[DataProvider('getTestsDataProvider')]
1820
public function testGet(array $data, ?string $name, Attribute $expectedAttribute): void
1921
{
2022
$data = new Data($data);
@@ -24,7 +26,7 @@ public function testGet(array $data, ?string $name, Attribute $expectedAttribute
2426
static::assertEquals($expectedAttribute, $attribute);
2527
}
2628

27-
public function getTestsDataProvider(): array
29+
public static function getTestsDataProvider(): array
2830
{
2931
return [
3032
[['foo' => 'bar'], null, new Attribute(null)],

tests/Rules/Core/IsFalseTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
namespace Kontrolio\Tests\Rules\Core;
55

6-
use Kontrolio\Rules\Core\IsTrue;
6+
use Kontrolio\Rules\Core\IsFalse;
77
use PHPUnit\Framework\TestCase;
88

9-
class IsTrueTest extends TestCase
9+
class IsFalseTest extends TestCase
1010
{
1111
public function testValidation(): void
1212
{
13-
$rule = new IsTrue;
14-
13+
$rule = new IsFalse;
14+
1515
static::assertFalse($rule->isValid('foo'));
1616
static::assertFalse($rule->isValid(''));
1717
static::assertFalse($rule->isValid());
18-
static::assertTrue($rule->isValid(true));
18+
static::assertTrue($rule->isValid(false));
1919
}
2020
}

tests/Rules/Core/IsInTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Kontrolio\Tests\Rules\Core;
55

66
use Kontrolio\Rules\Core\IsIn;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use PHPUnit\Framework\TestCase;
89

910
/**
@@ -21,6 +22,7 @@ class IsInTest extends TestCase
2122
* @param bool $expectedResult
2223
* @dataProvider dpValidation
2324
*/
25+
#[DataProvider('dpValidation')]
2426
public function testValidation(array $haystack, bool $strict, string $input, bool $expectedResult): void
2527
{
2628
$rule = new IsIn($haystack, $strict);
@@ -31,7 +33,7 @@ public function testValidation(array $haystack, bool $strict, string $input, boo
3133
);
3234
}
3335

34-
public function dpValidation(): array
36+
public static function dpValidation(): array
3537
{
3638
return [
3739
[

tests/Rules/Core/IsTrueTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
namespace Kontrolio\Tests\Rules\Core;
55

6-
use Kontrolio\Rules\Core\IsFalse;
6+
use Kontrolio\Rules\Core\IsTrue;
77
use PHPUnit\Framework\TestCase;
88

9-
class IsFalseTest extends TestCase
9+
class IsTrueTest extends TestCase
1010
{
1111
public function testValidation(): void
1212
{
13-
$rule = new IsFalse;
13+
$rule = new IsTrue;
1414

1515
static::assertFalse($rule->isValid('foo'));
1616
static::assertFalse($rule->isValid(''));
1717
static::assertFalse($rule->isValid());
18-
static::assertTrue($rule->isValid(false));
18+
static::assertTrue($rule->isValid(true));
1919
}
2020
}

tests/Rules/InstantiatorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Kontrolio\Rules\Instantiator;
99
use Kontrolio\Rules\RuleInterface;
1010
use Kontrolio\Validator;
11+
use PHPUnit\Framework\Attributes\DataProvider;
1112
use PHPUnit\Framework\TestCase;
1213
use ReflectionException;
1314
use UnexpectedValueException;
@@ -21,6 +22,7 @@ final class InstantiatorTest extends TestCase
2122
*
2223
* @throws ReflectionException
2324
*/
25+
#[DataProvider('exceptionDataProvider')]
2426
public function testThrowsIfClassIsNotInstantiable(string $class, string $message): void
2527
{
2628
$this->expectException(UnexpectedValueException::class);
@@ -29,7 +31,7 @@ public function testThrowsIfClassIsNotInstantiable(string $class, string $messag
2931
(new Instantiator())->make($class);
3032
}
3133

32-
public function exceptionDataProvider(): array
34+
public static function exceptionDataProvider(): array
3335
{
3436
return [
3537
[AbstractRule::class, 'Rule class must be instantiable.'],

0 commit comments

Comments
 (0)