Skip to content

Commit

Permalink
Rename assertArrayIsList() to assertIsList()
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Aug 11, 2022
1 parent 860e9d2 commit e04a947
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion ChangeLog-10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
* [#4641](https://github.com/sebastianbergmann/phpunit/issues/4641): `assertStringEqualsStringIgnoringLineEndings()` and `assertStringContainsStringIgnoringLineEndings()`
* [#4650](https://github.com/sebastianbergmann/phpunit/issues/4650): Support dist file name `phpunit.dist.xml`
* [#4657](https://github.com/sebastianbergmann/phpunit/pull/4657): `--exclude-testsuite` option
* [#4818](https://github.com/sebastianbergmann/phpunit/pull/4818): `assertArrayIsList()`
* [#4818](https://github.com/sebastianbergmann/phpunit/pull/4818): `assertIsList()`
* [#4892](https://github.com/sebastianbergmann/phpunit/issues/4892): Make colors used in HTML code coverage report configurable
* [#4893](https://github.com/sebastianbergmann/phpunit/issues/4893): Make path to custom.css for HTML code coverage report configurable
* `#[ExcludeGlobalVariableFromBackup('variable')]` attribute for excluding a global variable from the backup/restore of global and super-global variables
Expand Down
10 changes: 5 additions & 5 deletions src/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Generator;
use PHPUnit\Event;
use PHPUnit\Framework\Constraint\ArrayHasKey;
use PHPUnit\Framework\Constraint\ArrayIsList;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\Constraint\Count;
Expand All @@ -47,6 +46,7 @@
use PHPUnit\Framework\Constraint\IsInfinite;
use PHPUnit\Framework\Constraint\IsInstanceOf;
use PHPUnit\Framework\Constraint\IsJson;
use PHPUnit\Framework\Constraint\IsList;
use PHPUnit\Framework\Constraint\IsNan;
use PHPUnit\Framework\Constraint\IsNull;
use PHPUnit\Framework\Constraint\IsReadable;
Expand Down Expand Up @@ -108,11 +108,11 @@ final public static function assertArrayNotHasKey(int|string $key, array|ArrayAc
static::assertThat($array, $constraint, $message);
}

final public static function assertArrayIsList(array $array, string $message = ''): void
final public static function assertIsList(array $array, string $message = ''): void
{
static::assertThat(
$array,
new ArrayIsList,
new IsList,
$message
);
}
Expand Down Expand Up @@ -1975,9 +1975,9 @@ final public static function arrayHasKey(int|string $key): ArrayHasKey
return new ArrayHasKey($key);
}

final public static function arrayIsList(): ArrayIsList
final public static function isList(): IsList
{
return new ArrayIsList;
return new IsList;
}

final public static function equalTo(mixed $value): IsEqual
Expand Down
16 changes: 8 additions & 8 deletions src/Framework/Assert/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use ArrayAccess;
use Countable;
use PHPUnit\Framework\Constraint\ArrayHasKey;
use PHPUnit\Framework\Constraint\ArrayIsList;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\Constraint\ClassHasAttribute;
use PHPUnit\Framework\Constraint\ClassHasStaticAttribute;
Expand All @@ -35,6 +34,7 @@
use PHPUnit\Framework\Constraint\IsInfinite;
use PHPUnit\Framework\Constraint\IsInstanceOf;
use PHPUnit\Framework\Constraint\IsJson;
use PHPUnit\Framework\Constraint\IsList;
use PHPUnit\Framework\Constraint\IsNan;
use PHPUnit\Framework\Constraint\IsNull;
use PHPUnit\Framework\Constraint\IsReadable;
Expand Down Expand Up @@ -105,7 +105,7 @@ function assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string
}
}

if (!function_exists('PHPUnit\Framework\assertArrayIsList')) {
if (!function_exists('PHPUnit\Framework\assertIsList')) {
/**
* Asserts that an array is list.
*
Expand All @@ -114,11 +114,11 @@ function assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertArrayIsList()
* @see Assert::assertIsList()
*/
function assertArrayIsList(array $array, string $message = ''): void
function assertIsList(array $array, string $message = ''): void
{
Assert::assertArrayIsList(...func_get_args());
Assert::assertIsList(...func_get_args());
}
}

Expand Down Expand Up @@ -2400,10 +2400,10 @@ function arrayHasKey(int|string $key): ArrayHasKey
}
}

if (!function_exists('PHPUnit\Framework\arrayIsList')) {
function arrayIsList(): ArrayIsList
if (!function_exists('PHPUnit\Framework\isList')) {
function isList(): IsList
{
return Assert::arrayIsList();
return Assert::isList();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*/
final class ArrayIsList extends Constraint
final class IsList extends Constraint
{
/**
* Returns a string representation of the constraint.
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/Framework/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,25 @@ public function testAssertArrayNotHasKeyPropertlyFailsWithArrayAccessValue(): vo
$this->assertArrayNotHasKey('bar', $array);
}

public function testAssertArrayIsList(): void
public function testAssertIsList(): void
{
$this->assertArrayIsList([0, 1, 2]);
$this->assertIsList([0, 1, 2]);

$this->expectException(AssertionFailedError::class);

$this->assertArrayIsList([0 => 0, 2 => 2, 3 => 3]);
$this->assertIsList([0 => 0, 2 => 2, 3 => 3]);
}

public function testAssertArrayIsListWithEmptyArray(): void
public function testAssertIsListWithEmptyArray(): void
{
$this->assertArrayIsList([]);
$this->assertIsList([]);
}

public function testAssertArrayIsListFailsWithStringKeys(): void
public function testAssertIsListFailsWithStringKeys(): void
{
$this->expectException(AssertionFailedError::class);

$this->assertArrayIsList(['string' => 0]);
$this->assertIsList(['string' => 0]);
}

public function testAssertArrayContainsOnlyIntegers(): void
Expand Down Expand Up @@ -914,7 +914,7 @@ public function testAssertThatArrayHasKey(): void

public function testAssertThatArrayIsList(): void
{
$this->assertThat([0, 1, 2], $this->arrayIsList());
$this->assertThat([0, 1, 2], $this->isList());
}

public function testAssertThatEqualTo(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestFailure;

#[CoversClass(ArrayIsList::class)]
#[CoversClass(IsList::class)]
#[Small]
final class ArrayIsListTest extends ConstraintTestCase
final class IsListTest extends ConstraintTestCase
{
public function testConstraintArrayIsListWhenEmpty(): void
public function testConstraintIsListWhenEmpty(): void
{
$constraint = new ArrayIsList;
$constraint = new IsList;

$this->assertTrue($constraint->evaluate([], '', true));
}

public function testConstraintArrayIsNotList(): void
public function testConstraintIsNotList(): void
{
$constraint = new ArrayIsList;
$constraint = new IsList;

$this->assertFalse($constraint->evaluate([1 => 1], '', true));
$this->assertEquals('is list', $constraint->toString());
Expand All @@ -51,9 +51,9 @@ public function testConstraintArrayIsNotList(): void
$this->fail();
}

public function testConstraintArrayIsNotListWithFilteredArray(): void
public function testConstraintIsNotListWithFilteredArray(): void
{
$constraint = new ArrayIsList;
$constraint = new IsList;

$this->assertFalse($constraint->evaluate([0 => 0, 1 => 1, 3 => 3], '', true));
$this->assertEquals('is list', $constraint->toString());
Expand All @@ -77,9 +77,9 @@ public function testConstraintArrayIsNotListWithFilteredArray(): void
$this->fail();
}

public function testConstraintArrayIsNotListWithCustomMessage(): void
public function testConstraintIsNotListWithCustomMessage(): void
{
$constraint = new ArrayIsList;
$constraint = new IsList;

try {
$constraint->evaluate([1 => 1], 'custom message');
Expand All @@ -100,9 +100,9 @@ public function testConstraintArrayIsNotListWithCustomMessage(): void
$this->fail();
}

public function testConstraintArrayIsNotListWhenNotArray(): void
public function testConstraintIsNotListWhenNotArray(): void
{
$constraint = new ArrayIsList;
$constraint = new IsList;

try {
$constraint->evaluate('not array');
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Framework/ConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testConstraintArrayNotHasKey2(): void
public function testConstraintArrayIsNotList(): void
{
$constraint = Assert::logicalNot(
Assert::arrayIsList()
Assert::isList()
);

try {
Expand Down

0 comments on commit e04a947

Please sign in to comment.