Skip to content

Commit 095e55d

Browse files
authored
Merge pull request #1193 from crstauf/phpcs/LogMigrator_Test.php
PHPCS: `tests/phpunit/migration/LogMigrator_Test.php`
2 parents 5dcd596 + 0a66d48 commit 095e55d

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

tests/phpunit/migration/LogMigrator_Test.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
* @group migration
88
*/
99
class LogMigrator_Test extends ActionScheduler_UnitTestCase {
10-
function setUp() {
10+
public function setUp() {
1111
parent::setUp();
12-
if ( ! taxonomy_exists( ActionScheduler_wpPostStore::GROUP_TAXONOMY ) ) {
13-
// register the post type and taxonomy necessary for the store to work
12+
if ( ! taxonomy_exists( ActionScheduler_wpPostStore::GROUP_TAXONOMY ) ) {
13+
// register the post type and taxonomy necessary for the store to work.
1414
$store = new ActionScheduler_wpPostStore();
1515
$store->init();
1616
}
1717
}
1818

1919
public function test_migrate_from_wpComment_to_db() {
20-
$source = new ActionScheduler_wpCommentLogger();
21-
$destination = new ActionScheduler_DBLogger();
22-
$migrator = new LogMigrator( $source, $destination );
23-
$source_action_id = rand( 10, 10000 );
24-
$destination_action_id = rand( 10, 10000 );
20+
$source = new ActionScheduler_wpCommentLogger();
21+
$destination = new ActionScheduler_DBLogger();
22+
$migrator = new LogMigrator( $source, $destination );
23+
$source_action_id = wp_rand( 10, 10000 );
24+
$destination_action_id = wp_rand( 10, 10000 );
2525

26-
$logs = [];
27-
for ( $i = 0 ; $i < 3 ; $i++ ) {
28-
for ( $j = 0 ; $j < 5 ; $j++ ) {
29-
$logs[ $i ][ $j ] = md5(rand());
30-
if ( $i == 1 ) {
26+
$logs = array();
27+
for ( $i = 0; $i < 3; $i++ ) {
28+
for ( $j = 0; $j < 5; $j++ ) {
29+
$logs[ $i ][ $j ] = md5( wp_rand() );
30+
if ( 1 === $i ) {
3131
$source->log( $source_action_id, $logs[ $i ][ $j ] );
3232
}
3333
}
@@ -36,9 +36,17 @@ public function test_migrate_from_wpComment_to_db() {
3636
$migrator->migrate( $source_action_id, $destination_action_id );
3737

3838
$migrated = $destination->get_logs( $destination_action_id );
39-
$this->assertEqualSets( $logs[ 1 ], array_map( function( $log ) { return $log->get_message(); }, $migrated ) );
39+
$this->assertEqualSets(
40+
$logs[1],
41+
array_map(
42+
function( $log ) {
43+
return $log->get_message();
44+
},
45+
$migrated
46+
)
47+
);
4048

41-
// no API for deleting logs, so we leave them for manual cleanup later
49+
// no API for deleting logs, so we leave them for manual cleanup later.
4250
$this->assertCount( 5, $source->get_logs( $source_action_id ) );
4351
}
44-
}
52+
}

0 commit comments

Comments
 (0)