7
7
* @group migration
8
8
*/
9
9
class LogMigrator_Test extends ActionScheduler_UnitTestCase {
10
- function setUp () {
10
+ public function setUp () {
11
11
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.
14
14
$ store = new ActionScheduler_wpPostStore ();
15
15
$ store ->init ();
16
16
}
17
17
}
18
18
19
19
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 );
25
25
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 ) {
31
31
$ source ->log ( $ source_action_id , $ logs [ $ i ][ $ j ] );
32
32
}
33
33
}
@@ -36,9 +36,17 @@ public function test_migrate_from_wpComment_to_db() {
36
36
$ migrator ->migrate ( $ source_action_id , $ destination_action_id );
37
37
38
38
$ 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
+ );
40
48
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.
42
50
$ this ->assertCount ( 5 , $ source ->get_logs ( $ source_action_id ) );
43
51
}
44
- }
52
+ }
0 commit comments