Skip to content

Commit

Permalink
Issue #3126695 by mondrake: [D8 only] Add forwards-compatibility shim…
Browse files Browse the repository at this point in the history
… for assertEqualsCanonicalizing() in phpunit 6&7
  • Loading branch information
catch committed Apr 16, 2020
1 parent b6f8c48 commit a1118f6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,18 @@ public static function assertFalse($actual, $message = '') {
}
}

/**
* Forward compatibility for assertEqualsCanonicalizing.
*/
public static function assertEqualsCanonicalizing($expected, $actual, $message = '') {
static::assertEquals($expected, $actual, $message, 0.0, 10, TRUE);
}

/**
* Forward compatibility for assertNotEqualsCanonicalizing.
*/
public static function assertNotEqualsCanonicalizing($expected, $actual, $message = '') {
static::assertNotEquals($expected, $actual, $message, 0.0, 10, TRUE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,18 @@ public static function assertFalse($actual, string $message = ''): void {
}
}

/**
* Forward compatibility for assertEqualsCanonicalizing.
*/
public static function assertEqualsCanonicalizing($expected, $actual, string $message = ''): void {
static::assertEquals($expected, $actual, $message, 0.0, 10, TRUE);
}

/**
* Forward compatibility for assertNotEqualsCanonicalizing.
*/
public static function assertNotEqualsCanonicalizing($expected, $actual, string $message = ''): void {
static::assertNotEquals($expected, $actual, $message, 0.0, 10, TRUE);
}

}
11 changes: 11 additions & 0 deletions tests/Drupal/Tests/PhpunitCompatibilityTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public function testSetExpectedException() {
throw new \Exception($expectedMessage, $expectedCode);
}

/**
* Tests that assert(Not)EqualsCanonicalizing methods are available.
*
* @covers ::assertEqualsCanonicalizing
* @covers ::assertNotEqualsCanonicalizing
*/
public function testAssertEqualsCanonicalizing() {
$this->assertEqualsCanonicalizing([3, 2, 1], [2, 3, 1]);
$this->assertNotEqualsCanonicalizing([3, 2, 1], [2, 3, 0, 1]);
}

}

interface MockTestClassInterface {
Expand Down

0 comments on commit a1118f6

Please sign in to comment.