Remove usage of team specific names within PHP unit tests (#51017)

* Change team names in tests to generic names

* Add changelog
This commit is contained in:
louwie17 2024-09-03 15:29:45 +02:00 committed by GitHub
parent f44c0b8064
commit 82a00a56e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 17 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: tweak
Update PHP unit tests to remove specific team names for generic names.

View File

@ -58,20 +58,20 @@ class WC_Admin_Tests_RemoteInboxNotifications_Transformers_ArrayColumn extends W
public function test_it_returns_value_by_array_column() { public function test_it_returns_value_by_array_column() {
$items = array( $items = array(
array( array(
'name' => 'mothra', 'name' => 'team-a',
), ),
array( array(
'name' => 'gezora', 'name' => 'team-b',
), ),
array( array(
'name' => 'ghidorah', 'name' => 'team-c',
), ),
); );
$arguments = (object) array( 'key' => 'name' ); $arguments = (object) array( 'key' => 'name' );
$array_column = new ArrayColumn(); $array_column = new ArrayColumn();
$result = $array_column->transform( $items, $arguments ); $result = $array_column->transform( $items, $arguments );
$expected = array( 'mothra', 'gezora', 'ghidorah' ); $expected = array( 'team-a', 'team-b', 'team-c' );
$this->assertEquals( $expected, $result ); $this->assertEquals( $expected, $result );
} }
} }

View File

@ -51,11 +51,11 @@ class WC_Admin_Tests_RemoteInboxNotifications_Transformers_DotNotation extends W
* Test it get getvalue by dot notation. * Test it get getvalue by dot notation.
*/ */
public function test_it_can_get_value_by_dot_notation() { public function test_it_can_get_value_by_dot_notation() {
$arguments = (object) array( 'path' => 'teams.mothra' ); $arguments = (object) array( 'path' => 'teams.a' );
$items = array( $items = array(
'teams' => array( 'teams' => array(
'mothra' => 'nice!', 'a' => 'nice!',
), ),
); );
@ -72,7 +72,7 @@ class WC_Admin_Tests_RemoteInboxNotifications_Transformers_DotNotation extends W
$items = array( $items = array(
'teams' => array( 'teams' => array(
'mothra' => 'nice!', 'a' => 'nice!',
), ),
); );

View File

@ -109,24 +109,24 @@ class WC_Admin_Tests_RemoteInboxNotifications_TransformerService extends WC_Unit
* When it uses DotNotation to select 'teams' * When it uses DotNotation to select 'teams'
* When it uses ArrayColumn to select 'members' in 'teams' * When it uses ArrayColumn to select 'members' in 'teams'
* When it uses ArrayFlatten to flatten 'members' * When it uses ArrayFlatten to flatten 'members'
* When it uses ArraySearch to select 'mothra-member' * When it uses ArraySearch to select 'team-a'
* Then 'mothra-member' should be returned. * Then 'team-a-member' should be returned.
*/ */
public function test_it_returns_transformed_value() { public function test_it_returns_transformed_value() {
// Given. // Given.
$items = array( $items = array(
'teams' => array( 'teams' => array(
array( array(
'name' => 'mothra', 'name' => 'team-a',
'members' => array( 'mothra-member' ), 'members' => array( 'team-a-member' ),
), ),
array( array(
'name' => 'gezora', 'name' => 'team-b',
'members' => array( 'gezora-member' ), 'members' => array( 'team-b-member' ),
), ),
array( array(
'name' => 'ghidorah', 'name' => 'team-c',
'members' => array( 'ghidorah-member' ), 'members' => array( 'team-c-member' ),
), ),
), ),
); );
@ -135,12 +135,12 @@ class WC_Admin_Tests_RemoteInboxNotifications_TransformerService extends WC_Unit
$dot_notation = $this->transformer_config( 'dot_notation', array( 'path' => 'teams' ) ); $dot_notation = $this->transformer_config( 'dot_notation', array( 'path' => 'teams' ) );
$array_column = $this->transformer_config( 'array_column', array( 'key' => 'members' ) ); $array_column = $this->transformer_config( 'array_column', array( 'key' => 'members' ) );
$array_flatten = $this->transformer_config( 'array_flatten' ); $array_flatten = $this->transformer_config( 'array_flatten' );
$array_search = $this->transformer_config( 'array_search', array( 'value' => 'mothra-member' ) ); $array_search = $this->transformer_config( 'array_search', array( 'value' => 'team-a-member' ) );
$result = TransformerService::apply( $items, array( $dot_notation, $array_column, $array_flatten, $array_search ), false, null ); $result = TransformerService::apply( $items, array( $dot_notation, $array_column, $array_flatten, $array_search ), false, null );
// Then. // Then.
$this->assertEquals( 'mothra-member', $result ); $this->assertEquals( 'team-a-member', $result );
} }
/** /**