@@ -14,181 +14,181 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class WordPoints_Importer_Admin_Test extends WordPoints_Points_UnitTestCase { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Test that a points type must be supplied. |
|
| 19 | - * |
|
| 20 | - * @since 1.0.0 |
|
| 21 | - * |
|
| 22 | - * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 23 | - */ |
|
| 24 | - public function test_validate_points_type_setting_not_set() { |
|
| 25 | - |
|
| 26 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 27 | - |
|
| 28 | - $valid = wordpoints_importer_validate_points_type_setting( |
|
| 29 | - true |
|
| 30 | - , array() |
|
| 31 | - , $feedback |
|
| 32 | - ); |
|
| 33 | - |
|
| 34 | - $this->assertFalse( $valid ); |
|
| 35 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Test that the points type supplied must be valid. |
|
| 40 | - * |
|
| 41 | - * @since 1.0.0 |
|
| 42 | - * |
|
| 43 | - * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 44 | - */ |
|
| 45 | - public function test_validate_points_type_setting_invalid() { |
|
| 46 | - |
|
| 47 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 48 | - |
|
| 49 | - $valid = wordpoints_importer_validate_points_type_setting( |
|
| 50 | - true |
|
| 51 | - , array( 'points_type' => 'invalid' ) |
|
| 52 | - , $feedback |
|
| 53 | - ); |
|
| 54 | - |
|
| 55 | - $this->assertFalse( $valid ); |
|
| 56 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Test that it returns true when supplied a valid points type. |
|
| 61 | - * |
|
| 62 | - * @since 1.0.0 |
|
| 63 | - * |
|
| 64 | - * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 65 | - */ |
|
| 66 | - public function test_validate_points_type_setting_valid() { |
|
| 67 | - |
|
| 68 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 69 | - |
|
| 70 | - $valid = wordpoints_importer_validate_points_type_setting( |
|
| 71 | - true |
|
| 72 | - , array( 'points_type' => 'points' ) |
|
| 73 | - , $feedback |
|
| 74 | - ); |
|
| 75 | - |
|
| 76 | - $this->assertTrue( $valid ); |
|
| 77 | - $this->assertEmpty( $feedback->messages ); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Test that it returns false when supplied a valid points type if $valid is false. |
|
| 82 | - * |
|
| 83 | - * @since 1.0.0 |
|
| 84 | - * |
|
| 85 | - * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 86 | - */ |
|
| 87 | - public function test_validate_points_type_setting_valid_false() { |
|
| 88 | - |
|
| 89 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 90 | - |
|
| 91 | - $valid = wordpoints_importer_validate_points_type_setting( |
|
| 92 | - false |
|
| 93 | - , array( 'points_type' => 'points' ) |
|
| 94 | - , $feedback |
|
| 95 | - ); |
|
| 96 | - |
|
| 97 | - $this->assertFalse( $valid ); |
|
| 98 | - $this->assertEmpty( $feedback->messages ); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Test that a rank group must be supplied. |
|
| 103 | - * |
|
| 104 | - * @since 1.1.0 |
|
| 105 | - * |
|
| 106 | - * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 107 | - */ |
|
| 108 | - public function test_validate_rank_group_setting_not_set() { |
|
| 109 | - |
|
| 110 | - wordpoints_register_points_ranks(); |
|
| 111 | - |
|
| 112 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 113 | - |
|
| 114 | - $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 115 | - true |
|
| 116 | - , array() |
|
| 117 | - , $feedback |
|
| 118 | - ); |
|
| 119 | - |
|
| 120 | - $this->assertFalse( $valid ); |
|
| 121 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Test that the rank group supplied must be valid. |
|
| 126 | - * |
|
| 127 | - * @since 1.1.0 |
|
| 128 | - * |
|
| 129 | - * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 130 | - */ |
|
| 131 | - public function test_validate_rank_group_setting_invalid() { |
|
| 132 | - |
|
| 133 | - wordpoints_register_points_ranks(); |
|
| 134 | - |
|
| 135 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 136 | - |
|
| 137 | - $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 138 | - true |
|
| 139 | - , array( 'rank_group' => 'invalid' ) |
|
| 140 | - , $feedback |
|
| 141 | - ); |
|
| 142 | - |
|
| 143 | - $this->assertFalse( $valid ); |
|
| 144 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Test that it returns true when supplied a valid rank group. |
|
| 149 | - * |
|
| 150 | - * @since 1.1.0 |
|
| 151 | - * |
|
| 152 | - * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 153 | - */ |
|
| 154 | - public function test_validate_rank_group_setting_valid() { |
|
| 155 | - |
|
| 156 | - wordpoints_register_points_ranks(); |
|
| 157 | - |
|
| 158 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 159 | - |
|
| 160 | - $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 161 | - true |
|
| 162 | - , array( 'rank_group' => 'points_type-points' ) |
|
| 163 | - , $feedback |
|
| 164 | - ); |
|
| 165 | - |
|
| 166 | - $this->assertTrue( $valid ); |
|
| 167 | - $this->assertEmpty( $feedback->messages ); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Test that it returns false when supplied a valid rank group if $valid is false. |
|
| 172 | - * |
|
| 173 | - * @since 1.1.0 |
|
| 174 | - * |
|
| 175 | - * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 176 | - */ |
|
| 177 | - public function test_validate_rank_group_setting_valid_false() { |
|
| 178 | - |
|
| 179 | - wordpoints_register_points_ranks(); |
|
| 180 | - |
|
| 181 | - $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 182 | - |
|
| 183 | - $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 184 | - false |
|
| 185 | - , array( 'rank_group' => 'points_type-points' ) |
|
| 186 | - , $feedback |
|
| 187 | - ); |
|
| 188 | - |
|
| 189 | - $this->assertFalse( $valid ); |
|
| 190 | - $this->assertEmpty( $feedback->messages ); |
|
| 191 | - } |
|
| 17 | + /** |
|
| 18 | + * Test that a points type must be supplied. |
|
| 19 | + * |
|
| 20 | + * @since 1.0.0 |
|
| 21 | + * |
|
| 22 | + * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 23 | + */ |
|
| 24 | + public function test_validate_points_type_setting_not_set() { |
|
| 25 | + |
|
| 26 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 27 | + |
|
| 28 | + $valid = wordpoints_importer_validate_points_type_setting( |
|
| 29 | + true |
|
| 30 | + , array() |
|
| 31 | + , $feedback |
|
| 32 | + ); |
|
| 33 | + |
|
| 34 | + $this->assertFalse( $valid ); |
|
| 35 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Test that the points type supplied must be valid. |
|
| 40 | + * |
|
| 41 | + * @since 1.0.0 |
|
| 42 | + * |
|
| 43 | + * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 44 | + */ |
|
| 45 | + public function test_validate_points_type_setting_invalid() { |
|
| 46 | + |
|
| 47 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 48 | + |
|
| 49 | + $valid = wordpoints_importer_validate_points_type_setting( |
|
| 50 | + true |
|
| 51 | + , array( 'points_type' => 'invalid' ) |
|
| 52 | + , $feedback |
|
| 53 | + ); |
|
| 54 | + |
|
| 55 | + $this->assertFalse( $valid ); |
|
| 56 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Test that it returns true when supplied a valid points type. |
|
| 61 | + * |
|
| 62 | + * @since 1.0.0 |
|
| 63 | + * |
|
| 64 | + * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 65 | + */ |
|
| 66 | + public function test_validate_points_type_setting_valid() { |
|
| 67 | + |
|
| 68 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 69 | + |
|
| 70 | + $valid = wordpoints_importer_validate_points_type_setting( |
|
| 71 | + true |
|
| 72 | + , array( 'points_type' => 'points' ) |
|
| 73 | + , $feedback |
|
| 74 | + ); |
|
| 75 | + |
|
| 76 | + $this->assertTrue( $valid ); |
|
| 77 | + $this->assertEmpty( $feedback->messages ); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Test that it returns false when supplied a valid points type if $valid is false. |
|
| 82 | + * |
|
| 83 | + * @since 1.0.0 |
|
| 84 | + * |
|
| 85 | + * @covers ::wordpoints_importer_validate_points_type_setting |
|
| 86 | + */ |
|
| 87 | + public function test_validate_points_type_setting_valid_false() { |
|
| 88 | + |
|
| 89 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 90 | + |
|
| 91 | + $valid = wordpoints_importer_validate_points_type_setting( |
|
| 92 | + false |
|
| 93 | + , array( 'points_type' => 'points' ) |
|
| 94 | + , $feedback |
|
| 95 | + ); |
|
| 96 | + |
|
| 97 | + $this->assertFalse( $valid ); |
|
| 98 | + $this->assertEmpty( $feedback->messages ); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Test that a rank group must be supplied. |
|
| 103 | + * |
|
| 104 | + * @since 1.1.0 |
|
| 105 | + * |
|
| 106 | + * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 107 | + */ |
|
| 108 | + public function test_validate_rank_group_setting_not_set() { |
|
| 109 | + |
|
| 110 | + wordpoints_register_points_ranks(); |
|
| 111 | + |
|
| 112 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 113 | + |
|
| 114 | + $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 115 | + true |
|
| 116 | + , array() |
|
| 117 | + , $feedback |
|
| 118 | + ); |
|
| 119 | + |
|
| 120 | + $this->assertFalse( $valid ); |
|
| 121 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Test that the rank group supplied must be valid. |
|
| 126 | + * |
|
| 127 | + * @since 1.1.0 |
|
| 128 | + * |
|
| 129 | + * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 130 | + */ |
|
| 131 | + public function test_validate_rank_group_setting_invalid() { |
|
| 132 | + |
|
| 133 | + wordpoints_register_points_ranks(); |
|
| 134 | + |
|
| 135 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 136 | + |
|
| 137 | + $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 138 | + true |
|
| 139 | + , array( 'rank_group' => 'invalid' ) |
|
| 140 | + , $feedback |
|
| 141 | + ); |
|
| 142 | + |
|
| 143 | + $this->assertFalse( $valid ); |
|
| 144 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Test that it returns true when supplied a valid rank group. |
|
| 149 | + * |
|
| 150 | + * @since 1.1.0 |
|
| 151 | + * |
|
| 152 | + * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 153 | + */ |
|
| 154 | + public function test_validate_rank_group_setting_valid() { |
|
| 155 | + |
|
| 156 | + wordpoints_register_points_ranks(); |
|
| 157 | + |
|
| 158 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 159 | + |
|
| 160 | + $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 161 | + true |
|
| 162 | + , array( 'rank_group' => 'points_type-points' ) |
|
| 163 | + , $feedback |
|
| 164 | + ); |
|
| 165 | + |
|
| 166 | + $this->assertTrue( $valid ); |
|
| 167 | + $this->assertEmpty( $feedback->messages ); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Test that it returns false when supplied a valid rank group if $valid is false. |
|
| 172 | + * |
|
| 173 | + * @since 1.1.0 |
|
| 174 | + * |
|
| 175 | + * @covers ::wordpoints_importer_validate_rank_group_setting |
|
| 176 | + */ |
|
| 177 | + public function test_validate_rank_group_setting_valid_false() { |
|
| 178 | + |
|
| 179 | + wordpoints_register_points_ranks(); |
|
| 180 | + |
|
| 181 | + $feedback = new WordPoints_Importer_Tests_Feedback; |
|
| 182 | + |
|
| 183 | + $valid = wordpoints_importer_validate_rank_group_setting( |
|
| 184 | + false |
|
| 185 | + , array( 'rank_group' => 'points_type-points' ) |
|
| 186 | + , $feedback |
|
| 187 | + ); |
|
| 188 | + |
|
| 189 | + $this->assertFalse( $valid ); |
|
| 190 | + $this->assertEmpty( $feedback->messages ); |
|
| 191 | + } |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // EOF |
@@ -18,37 +18,37 @@ |
||
| 18 | 18 | * @coversNothing |
| 19 | 19 | */ |
| 20 | 20 | class WordPoints_CubePoints_Importer_Post_Publish_Hook_Test |
| 21 | - extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 21 | + extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @since 1.2.0 |
|
| 25 | - */ |
|
| 26 | - protected $cubepoints_option = 'cp_post_points'; |
|
| 23 | + /** |
|
| 24 | + * @since 1.2.0 |
|
| 25 | + */ |
|
| 26 | + protected $cubepoints_option = 'cp_post_points'; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @since 1.2.0 |
|
| 30 | - * |
|
| 31 | - * @dataProvider data_provider_types |
|
| 32 | - */ |
|
| 33 | - public function test( $type ) { |
|
| 28 | + /** |
|
| 29 | + * @since 1.2.0 |
|
| 30 | + * |
|
| 31 | + * @dataProvider data_provider_types |
|
| 32 | + */ |
|
| 33 | + public function test( $type ) { |
|
| 34 | 34 | |
| 35 | - $this->before( $type ); |
|
| 35 | + $this->before( $type ); |
|
| 36 | 36 | |
| 37 | - $user_id = $this->factory->user->create(); |
|
| 38 | - $post_id = $this->factory->post->create( |
|
| 39 | - array( 'post_author' => $user_id, 'post_status' => 'publish' ) |
|
| 40 | - ); |
|
| 37 | + $user_id = $this->factory->user->create(); |
|
| 38 | + $post_id = $this->factory->post->create( |
|
| 39 | + array( 'post_author' => $user_id, 'post_status' => 'publish' ) |
|
| 40 | + ); |
|
| 41 | 41 | |
| 42 | - $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 42 | + $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 43 | 43 | |
| 44 | - wp_update_post( array( 'ID' => $post_id, 'post_status' => 'draft' ) ); |
|
| 44 | + wp_update_post( array( 'ID' => $post_id, 'post_status' => 'draft' ) ); |
|
| 45 | 45 | |
| 46 | - $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 46 | + $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 47 | 47 | |
| 48 | - wp_delete_post( $post_id, true ); |
|
| 48 | + wp_delete_post( $post_id, true ); |
|
| 49 | 49 | |
| 50 | - $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 51 | - } |
|
| 50 | + $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // EOF |
@@ -18,51 +18,51 @@ |
||
| 18 | 18 | * @coversNothing |
| 19 | 19 | */ |
| 20 | 20 | class WordPoints_CubePoints_Importer_Comment_Leave_Hook_Test |
| 21 | - extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 21 | + extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @since 1.2.0 |
|
| 25 | - */ |
|
| 26 | - protected $cubepoints_option = 'cp_comment_points'; |
|
| 23 | + /** |
|
| 24 | + * @since 1.2.0 |
|
| 25 | + */ |
|
| 26 | + protected $cubepoints_option = 'cp_comment_points'; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @since 1.2.0 |
|
| 30 | - * |
|
| 31 | - * @dataProvider data_provider_types |
|
| 32 | - */ |
|
| 33 | - public function test( $type ) { |
|
| 28 | + /** |
|
| 29 | + * @since 1.2.0 |
|
| 30 | + * |
|
| 31 | + * @dataProvider data_provider_types |
|
| 32 | + */ |
|
| 33 | + public function test( $type ) { |
|
| 34 | 34 | |
| 35 | - $this->before( $type ); |
|
| 35 | + $this->before( $type ); |
|
| 36 | 36 | |
| 37 | - update_option( 'cp_del_comment_points', 10 ); |
|
| 37 | + update_option( 'cp_del_comment_points', 10 ); |
|
| 38 | 38 | |
| 39 | - $user_id = $this->factory->user->create(); |
|
| 40 | - $post_id = $this->factory->post->create( |
|
| 41 | - array( 'post_author' => $this->factory->user->create() ) |
|
| 42 | - ); |
|
| 39 | + $user_id = $this->factory->user->create(); |
|
| 40 | + $post_id = $this->factory->post->create( |
|
| 41 | + array( 'post_author' => $this->factory->user->create() ) |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | - $comment_id = $this->factory->comment->create( |
|
| 45 | - array( |
|
| 46 | - 'comment_post_ID' => $post_id, |
|
| 47 | - 'comment_approved' => 0, |
|
| 48 | - 'user_id' => $user_id, |
|
| 49 | - ) |
|
| 50 | - ); |
|
| 44 | + $comment_id = $this->factory->comment->create( |
|
| 45 | + array( |
|
| 46 | + 'comment_post_ID' => $post_id, |
|
| 47 | + 'comment_approved' => 0, |
|
| 48 | + 'user_id' => $user_id, |
|
| 49 | + ) |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | - $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 52 | + $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 53 | 53 | |
| 54 | - wp_update_comment( |
|
| 55 | - array( 'comment_ID' => $comment_id, 'comment_approved' => 1 ) |
|
| 56 | - ); |
|
| 54 | + wp_update_comment( |
|
| 55 | + array( 'comment_ID' => $comment_id, 'comment_approved' => 1 ) |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | - $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 58 | + $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 59 | 59 | |
| 60 | - wp_update_comment( |
|
| 61 | - array( 'comment_ID' => $comment_id, 'comment_approved' => 0 ) |
|
| 62 | - ); |
|
| 60 | + wp_update_comment( |
|
| 61 | + array( 'comment_ID' => $comment_id, 'comment_approved' => 0 ) |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 65 | - } |
|
| 64 | + $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 65 | + } |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // EOF |
@@ -18,53 +18,53 @@ |
||
| 18 | 18 | * @coversNothing |
| 19 | 19 | */ |
| 20 | 20 | class WordPoints_CubePoints_Importer_Comment_Receive_Hook_Test |
| 21 | - extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 21 | + extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @since 1.2.0 |
|
| 25 | - */ |
|
| 26 | - protected $cubepoints_option = 'cp_post_author_points'; |
|
| 23 | + /** |
|
| 24 | + * @since 1.2.0 |
|
| 25 | + */ |
|
| 26 | + protected $cubepoints_option = 'cp_post_author_points'; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @since 1.2.0 |
|
| 30 | - * |
|
| 31 | - * @dataProvider data_provider_types |
|
| 32 | - */ |
|
| 33 | - public function test( $type ) { |
|
| 28 | + /** |
|
| 29 | + * @since 1.2.0 |
|
| 30 | + * |
|
| 31 | + * @dataProvider data_provider_types |
|
| 32 | + */ |
|
| 33 | + public function test( $type ) { |
|
| 34 | 34 | |
| 35 | - cp_module_activation_set( 'post_author_points', 'active' ); |
|
| 35 | + cp_module_activation_set( 'post_author_points', 'active' ); |
|
| 36 | 36 | |
| 37 | - update_option( 'cp_post_points', 0 ); |
|
| 37 | + update_option( 'cp_post_points', 0 ); |
|
| 38 | 38 | |
| 39 | - $this->before( $type ); |
|
| 39 | + $this->before( $type ); |
|
| 40 | 40 | |
| 41 | - $user_id = $this->factory->user->create(); |
|
| 42 | - $post_id = $this->factory->post->create( |
|
| 43 | - array( 'post_author' => $user_id ) |
|
| 44 | - ); |
|
| 41 | + $user_id = $this->factory->user->create(); |
|
| 42 | + $post_id = $this->factory->post->create( |
|
| 43 | + array( 'post_author' => $user_id ) |
|
| 44 | + ); |
|
| 45 | 45 | |
| 46 | - $comment_id = $this->factory->comment->create( |
|
| 47 | - array( |
|
| 48 | - 'comment_post_ID' => $post_id, |
|
| 49 | - 'comment_approved' => 0, |
|
| 50 | - 'user_id' => $this->factory->user->create(), |
|
| 51 | - ) |
|
| 52 | - ); |
|
| 46 | + $comment_id = $this->factory->comment->create( |
|
| 47 | + array( |
|
| 48 | + 'comment_post_ID' => $post_id, |
|
| 49 | + 'comment_approved' => 0, |
|
| 50 | + 'user_id' => $this->factory->user->create(), |
|
| 51 | + ) |
|
| 52 | + ); |
|
| 53 | 53 | |
| 54 | - $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 54 | + $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 55 | 55 | |
| 56 | - wp_update_comment( |
|
| 57 | - array( 'comment_ID' => $comment_id, 'comment_approved' => 1 ) |
|
| 58 | - ); |
|
| 56 | + wp_update_comment( |
|
| 57 | + array( 'comment_ID' => $comment_id, 'comment_approved' => 1 ) |
|
| 58 | + ); |
|
| 59 | 59 | |
| 60 | - $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 60 | + $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 61 | 61 | |
| 62 | - wp_update_comment( |
|
| 63 | - array( 'comment_ID' => $comment_id, 'comment_approved' => 0 ) |
|
| 64 | - ); |
|
| 62 | + wp_update_comment( |
|
| 63 | + array( 'comment_ID' => $comment_id, 'comment_approved' => 0 ) |
|
| 64 | + ); |
|
| 65 | 65 | |
| 66 | - $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 67 | - } |
|
| 66 | + $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // EOF |
@@ -18,30 +18,30 @@ |
||
| 18 | 18 | * @coversNothing |
| 19 | 19 | */ |
| 20 | 20 | class WordPoints_CubePoints_Importer_User_Register_Hook_Test |
| 21 | - extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 21 | + extends WordPoints_Importer_Hook_UnitTestCase { |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @since 1.2.0 |
|
| 25 | - */ |
|
| 26 | - protected $cubepoints_option = 'cp_reg_points'; |
|
| 23 | + /** |
|
| 24 | + * @since 1.2.0 |
|
| 25 | + */ |
|
| 26 | + protected $cubepoints_option = 'cp_reg_points'; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @since 1.2.0 |
|
| 30 | - * |
|
| 31 | - * @dataProvider data_provider_types |
|
| 32 | - */ |
|
| 33 | - public function test( $type ) { |
|
| 28 | + /** |
|
| 29 | + * @since 1.2.0 |
|
| 30 | + * |
|
| 31 | + * @dataProvider data_provider_types |
|
| 32 | + */ |
|
| 33 | + public function test( $type ) { |
|
| 34 | 34 | |
| 35 | - $this->before( $type ); |
|
| 35 | + $this->before( $type ); |
|
| 36 | 36 | |
| 37 | - $user_id = $this->factory->user->create(); |
|
| 37 | + $user_id = $this->factory->user->create(); |
|
| 38 | 38 | |
| 39 | - $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 39 | + $this->assertEquals( 10, $this->get_user_points( $user_id ) ); |
|
| 40 | 40 | |
| 41 | - self::delete_user( $user_id ); |
|
| 41 | + self::delete_user( $user_id ); |
|
| 42 | 42 | |
| 43 | - $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 44 | - } |
|
| 43 | + $this->assertEquals( 0, $this->get_user_points( $user_id ) ); |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // EOF |
@@ -16,295 +16,295 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class WordPoints_Importer_Importer_Test extends WordPoints_UnitTestCase { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The mock importer used in the tests. |
|
| 21 | - * |
|
| 22 | - * @since 1.0.0 |
|
| 23 | - * |
|
| 24 | - * @var WordPoints_Importer_Mock |
|
| 25 | - */ |
|
| 26 | - protected $importer; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * The components assigned to the mock importer. |
|
| 30 | - * |
|
| 31 | - * @since 1.0.0 |
|
| 32 | - * |
|
| 33 | - * @var array[] |
|
| 34 | - */ |
|
| 35 | - protected $importer_components; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - */ |
|
| 40 | - public function setUp() { |
|
| 41 | - |
|
| 42 | - parent::setUp(); |
|
| 43 | - |
|
| 44 | - $this->importer = new WordPoints_Importer_Mock( 'Mock' ); |
|
| 45 | - $this->importer->components = array( |
|
| 46 | - 'points' => array( |
|
| 47 | - 'user_points' => array( |
|
| 48 | - 'label' => 'User points', |
|
| 49 | - 'function' => array( $this->importer, 'do_an_import' ), |
|
| 50 | - 'can_import' => array( $this->importer, 'can_import' ), |
|
| 51 | - ), |
|
| 52 | - ), |
|
| 53 | - ); |
|
| 54 | - |
|
| 55 | - $this->importer_components = $this->importer->components; |
|
| 56 | - |
|
| 57 | - remove_action( |
|
| 58 | - 'wordpoints_import_settings_valid-points' |
|
| 59 | - , 'wordpoints_importer_validate_points_type_setting' |
|
| 60 | - ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Test that it returns true when a component is supported. |
|
| 65 | - * |
|
| 66 | - * @since 1.0.0 |
|
| 67 | - * |
|
| 68 | - * @covers WordPoints_Importer::supports_component |
|
| 69 | - */ |
|
| 70 | - public function test_supports_supported_component() { |
|
| 71 | - |
|
| 72 | - $this->assertTrue( $this->importer->supports_component( 'points' ) ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Test that it returns false when a component isn't supported. |
|
| 77 | - * |
|
| 78 | - * @since 1.0.0 |
|
| 79 | - * |
|
| 80 | - * @covers WordPoints_Importer::supports_component |
|
| 81 | - */ |
|
| 82 | - public function test_supports_unsupported_component() { |
|
| 83 | - |
|
| 84 | - $this->assertFalse( $this->importer->supports_component( 'unsupported' ) ); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Test that it returns the settings for a component. |
|
| 89 | - * |
|
| 90 | - * @since 1.0.0 |
|
| 91 | - * |
|
| 92 | - * @covers WordPoints_Importer::get_options_for_component |
|
| 93 | - */ |
|
| 94 | - public function test_get_options_for_component() { |
|
| 95 | - |
|
| 96 | - $this->assertEquals( |
|
| 97 | - $this->importer_components['points'] |
|
| 98 | - , $this->importer->get_options_for_component( 'points' ) |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Test that it returns the settings for an unsupported component. |
|
| 104 | - * |
|
| 105 | - * @since 1.0.0 |
|
| 106 | - * |
|
| 107 | - * @covers WordPoints_Importer::get_options_for_component |
|
| 108 | - */ |
|
| 109 | - public function test_get_options_for_unsupported_component() { |
|
| 110 | - |
|
| 111 | - $this->assertEquals( |
|
| 112 | - array() |
|
| 113 | - , $this->importer->get_options_for_component( 'unsupported' ) |
|
| 114 | - ); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Test that it gives a warning for uninstalled components. |
|
| 119 | - * |
|
| 120 | - * @since 1.0.0 |
|
| 121 | - * |
|
| 122 | - * @covers WordPoints_Importer::do_import |
|
| 123 | - */ |
|
| 124 | - public function test_do_import_not_installed() { |
|
| 125 | - |
|
| 126 | - $this->importer->components = array( |
|
| 127 | - 'uninstalled' => array( 'method' => 'do_an_import' ), |
|
| 128 | - ); |
|
| 129 | - |
|
| 130 | - $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 131 | - $this->importer->do_import( |
|
| 132 | - array( 'uninstalled' => array( 'do' => 'yes' ) ) |
|
| 133 | - , $feedback |
|
| 134 | - ); |
|
| 135 | - |
|
| 136 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 137 | - |
|
| 138 | - // The import shouldn't have been performed. |
|
| 139 | - $this->assertEmpty( $this->importer->imports ); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Test that it gives a warning for unsupported components. |
|
| 144 | - * |
|
| 145 | - * @since 1.0.0 |
|
| 146 | - * |
|
| 147 | - * @covers WordPoints_Importer::do_import |
|
| 148 | - */ |
|
| 149 | - public function test_do_import_not_supported() { |
|
| 150 | - |
|
| 151 | - $this->importer->components = array(); |
|
| 152 | - |
|
| 153 | - $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 154 | - $this->importer->do_import( |
|
| 155 | - array( 'points' => array( 'do' => 'yes' ) ) |
|
| 156 | - , $feedback |
|
| 157 | - ); |
|
| 158 | - |
|
| 159 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 160 | - |
|
| 161 | - // The import shouldn't have been performed. |
|
| 162 | - $this->assertEmpty( $this->importer->imports ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Test that it skips a component if validation fails. |
|
| 167 | - * |
|
| 168 | - * @since 1.0.0 |
|
| 169 | - * |
|
| 170 | - * @covers WordPoints_Importer::do_import |
|
| 171 | - */ |
|
| 172 | - public function test_do_import_validates_settings() { |
|
| 173 | - |
|
| 174 | - $this->listen_for_filter( 'wordpoints_import_settings_valid-points' ); |
|
| 175 | - |
|
| 176 | - add_filter( 'wordpoints_import_settings_valid-points', '__return_false' ); |
|
| 177 | - |
|
| 178 | - $this->importer->do_import( |
|
| 179 | - array( 'points' => array( 'do' => 'yes' ) ) |
|
| 180 | - , new WordPoints_Importer_Tests_Feedback() |
|
| 181 | - ); |
|
| 182 | - |
|
| 183 | - $this->assertEquals( |
|
| 184 | - 1 |
|
| 185 | - , $this->filter_was_called( 'wordpoints_import_settings_valid-points' ) |
|
| 186 | - ); |
|
| 187 | - |
|
| 188 | - // The import shouldn't have been performed. |
|
| 189 | - $this->assertEmpty( $this->importer->imports ); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Test that it skips an unsupported option. |
|
| 194 | - * |
|
| 195 | - * @since 1.0.0 |
|
| 196 | - * |
|
| 197 | - * @covers WordPoints_Importer::do_import |
|
| 198 | - */ |
|
| 199 | - public function test_do_import_invalid_option() { |
|
| 200 | - |
|
| 201 | - $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 202 | - |
|
| 203 | - $this->importer->do_import( |
|
| 204 | - array( 'points' => array( 'do' => 'yes' ) ) |
|
| 205 | - , $feedback |
|
| 206 | - ); |
|
| 207 | - |
|
| 208 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 209 | - |
|
| 210 | - // The import shouldn't have been performed. |
|
| 211 | - $this->assertEmpty( $this->importer->imports ); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Test that it skips a disabled option. |
|
| 216 | - * |
|
| 217 | - * @since 1.0.0 |
|
| 218 | - * |
|
| 219 | - * @covers WordPoints_Importer::do_import |
|
| 220 | - */ |
|
| 221 | - public function test_do_import_disabled_option() { |
|
| 222 | - |
|
| 223 | - $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 224 | - |
|
| 225 | - $this->importer->components['points']['user_points']['can_import'] = |
|
| 226 | - array( $this->importer, 'cant_import' ); |
|
| 227 | - |
|
| 228 | - $this->importer->do_import( |
|
| 229 | - array( 'points' => array( 'user_points' => '1' ) ) |
|
| 230 | - , $feedback |
|
| 231 | - ); |
|
| 232 | - |
|
| 233 | - $this->assertCount( 1, $this->importer->can_imports ); |
|
| 234 | - $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 235 | - |
|
| 236 | - // The import shouldn't have been performed. |
|
| 237 | - $this->assertEmpty( $this->importer->imports ); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * Test that the can_import function is passed any settings. |
|
| 242 | - * |
|
| 243 | - * @since 1.0.0 |
|
| 244 | - * |
|
| 245 | - * @covers WordPoints_Importer::do_import |
|
| 246 | - */ |
|
| 247 | - public function test_do_import_can_import_passed_settings() { |
|
| 248 | - |
|
| 249 | - $this->importer->do_import( |
|
| 250 | - array( |
|
| 251 | - 'points' => array( |
|
| 252 | - 'user_points' => '1', |
|
| 253 | - '_data' => array( 'testing' => 1 ), |
|
| 254 | - ), |
|
| 255 | - ) |
|
| 256 | - , new WordPoints_Importer_Tests_Feedback() |
|
| 257 | - ); |
|
| 258 | - |
|
| 259 | - $this->assertCount( 1, $this->importer->can_imports ); |
|
| 260 | - $this->assertEquals( |
|
| 261 | - array( 'testing' => 1 ) |
|
| 262 | - , $this->importer->can_imports[0] |
|
| 263 | - ); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Test that it calls the importer function. |
|
| 268 | - * |
|
| 269 | - * @since 1.0.0 |
|
| 270 | - * |
|
| 271 | - * @covers WordPoints_Importer::do_import |
|
| 272 | - */ |
|
| 273 | - public function test_do_import() { |
|
| 274 | - |
|
| 275 | - $this->importer->do_import( |
|
| 276 | - array( 'points' => array( 'user_points' => '1' ) ) |
|
| 277 | - , new WordPoints_Importer_Tests_Feedback() |
|
| 278 | - ); |
|
| 279 | - |
|
| 280 | - $this->assertCount( 1, $this->importer->imports ); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Test that the import function is passed any settings. |
|
| 285 | - * |
|
| 286 | - * @since 1.0.0 |
|
| 287 | - * |
|
| 288 | - * @covers WordPoints_Importer::do_import |
|
| 289 | - */ |
|
| 290 | - public function test_do_import_passed_settings() { |
|
| 291 | - |
|
| 292 | - $this->importer->do_import( |
|
| 293 | - array( |
|
| 294 | - 'points' => array( |
|
| 295 | - 'user_points' => '1', |
|
| 296 | - '_data' => array( 'testing' => 1 ), |
|
| 297 | - ), |
|
| 298 | - ) |
|
| 299 | - , new WordPoints_Importer_Tests_Feedback() |
|
| 300 | - ); |
|
| 301 | - |
|
| 302 | - $this->assertCount( 1, $this->importer->imports ); |
|
| 303 | - $this->assertEquals( |
|
| 304 | - array( 'testing' => 1 ) |
|
| 305 | - , $this->importer->imports[0] |
|
| 306 | - ); |
|
| 307 | - } |
|
| 19 | + /** |
|
| 20 | + * The mock importer used in the tests. |
|
| 21 | + * |
|
| 22 | + * @since 1.0.0 |
|
| 23 | + * |
|
| 24 | + * @var WordPoints_Importer_Mock |
|
| 25 | + */ |
|
| 26 | + protected $importer; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * The components assigned to the mock importer. |
|
| 30 | + * |
|
| 31 | + * @since 1.0.0 |
|
| 32 | + * |
|
| 33 | + * @var array[] |
|
| 34 | + */ |
|
| 35 | + protected $importer_components; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + */ |
|
| 40 | + public function setUp() { |
|
| 41 | + |
|
| 42 | + parent::setUp(); |
|
| 43 | + |
|
| 44 | + $this->importer = new WordPoints_Importer_Mock( 'Mock' ); |
|
| 45 | + $this->importer->components = array( |
|
| 46 | + 'points' => array( |
|
| 47 | + 'user_points' => array( |
|
| 48 | + 'label' => 'User points', |
|
| 49 | + 'function' => array( $this->importer, 'do_an_import' ), |
|
| 50 | + 'can_import' => array( $this->importer, 'can_import' ), |
|
| 51 | + ), |
|
| 52 | + ), |
|
| 53 | + ); |
|
| 54 | + |
|
| 55 | + $this->importer_components = $this->importer->components; |
|
| 56 | + |
|
| 57 | + remove_action( |
|
| 58 | + 'wordpoints_import_settings_valid-points' |
|
| 59 | + , 'wordpoints_importer_validate_points_type_setting' |
|
| 60 | + ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Test that it returns true when a component is supported. |
|
| 65 | + * |
|
| 66 | + * @since 1.0.0 |
|
| 67 | + * |
|
| 68 | + * @covers WordPoints_Importer::supports_component |
|
| 69 | + */ |
|
| 70 | + public function test_supports_supported_component() { |
|
| 71 | + |
|
| 72 | + $this->assertTrue( $this->importer->supports_component( 'points' ) ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Test that it returns false when a component isn't supported. |
|
| 77 | + * |
|
| 78 | + * @since 1.0.0 |
|
| 79 | + * |
|
| 80 | + * @covers WordPoints_Importer::supports_component |
|
| 81 | + */ |
|
| 82 | + public function test_supports_unsupported_component() { |
|
| 83 | + |
|
| 84 | + $this->assertFalse( $this->importer->supports_component( 'unsupported' ) ); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Test that it returns the settings for a component. |
|
| 89 | + * |
|
| 90 | + * @since 1.0.0 |
|
| 91 | + * |
|
| 92 | + * @covers WordPoints_Importer::get_options_for_component |
|
| 93 | + */ |
|
| 94 | + public function test_get_options_for_component() { |
|
| 95 | + |
|
| 96 | + $this->assertEquals( |
|
| 97 | + $this->importer_components['points'] |
|
| 98 | + , $this->importer->get_options_for_component( 'points' ) |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Test that it returns the settings for an unsupported component. |
|
| 104 | + * |
|
| 105 | + * @since 1.0.0 |
|
| 106 | + * |
|
| 107 | + * @covers WordPoints_Importer::get_options_for_component |
|
| 108 | + */ |
|
| 109 | + public function test_get_options_for_unsupported_component() { |
|
| 110 | + |
|
| 111 | + $this->assertEquals( |
|
| 112 | + array() |
|
| 113 | + , $this->importer->get_options_for_component( 'unsupported' ) |
|
| 114 | + ); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Test that it gives a warning for uninstalled components. |
|
| 119 | + * |
|
| 120 | + * @since 1.0.0 |
|
| 121 | + * |
|
| 122 | + * @covers WordPoints_Importer::do_import |
|
| 123 | + */ |
|
| 124 | + public function test_do_import_not_installed() { |
|
| 125 | + |
|
| 126 | + $this->importer->components = array( |
|
| 127 | + 'uninstalled' => array( 'method' => 'do_an_import' ), |
|
| 128 | + ); |
|
| 129 | + |
|
| 130 | + $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 131 | + $this->importer->do_import( |
|
| 132 | + array( 'uninstalled' => array( 'do' => 'yes' ) ) |
|
| 133 | + , $feedback |
|
| 134 | + ); |
|
| 135 | + |
|
| 136 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 137 | + |
|
| 138 | + // The import shouldn't have been performed. |
|
| 139 | + $this->assertEmpty( $this->importer->imports ); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Test that it gives a warning for unsupported components. |
|
| 144 | + * |
|
| 145 | + * @since 1.0.0 |
|
| 146 | + * |
|
| 147 | + * @covers WordPoints_Importer::do_import |
|
| 148 | + */ |
|
| 149 | + public function test_do_import_not_supported() { |
|
| 150 | + |
|
| 151 | + $this->importer->components = array(); |
|
| 152 | + |
|
| 153 | + $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 154 | + $this->importer->do_import( |
|
| 155 | + array( 'points' => array( 'do' => 'yes' ) ) |
|
| 156 | + , $feedback |
|
| 157 | + ); |
|
| 158 | + |
|
| 159 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 160 | + |
|
| 161 | + // The import shouldn't have been performed. |
|
| 162 | + $this->assertEmpty( $this->importer->imports ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Test that it skips a component if validation fails. |
|
| 167 | + * |
|
| 168 | + * @since 1.0.0 |
|
| 169 | + * |
|
| 170 | + * @covers WordPoints_Importer::do_import |
|
| 171 | + */ |
|
| 172 | + public function test_do_import_validates_settings() { |
|
| 173 | + |
|
| 174 | + $this->listen_for_filter( 'wordpoints_import_settings_valid-points' ); |
|
| 175 | + |
|
| 176 | + add_filter( 'wordpoints_import_settings_valid-points', '__return_false' ); |
|
| 177 | + |
|
| 178 | + $this->importer->do_import( |
|
| 179 | + array( 'points' => array( 'do' => 'yes' ) ) |
|
| 180 | + , new WordPoints_Importer_Tests_Feedback() |
|
| 181 | + ); |
|
| 182 | + |
|
| 183 | + $this->assertEquals( |
|
| 184 | + 1 |
|
| 185 | + , $this->filter_was_called( 'wordpoints_import_settings_valid-points' ) |
|
| 186 | + ); |
|
| 187 | + |
|
| 188 | + // The import shouldn't have been performed. |
|
| 189 | + $this->assertEmpty( $this->importer->imports ); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Test that it skips an unsupported option. |
|
| 194 | + * |
|
| 195 | + * @since 1.0.0 |
|
| 196 | + * |
|
| 197 | + * @covers WordPoints_Importer::do_import |
|
| 198 | + */ |
|
| 199 | + public function test_do_import_invalid_option() { |
|
| 200 | + |
|
| 201 | + $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 202 | + |
|
| 203 | + $this->importer->do_import( |
|
| 204 | + array( 'points' => array( 'do' => 'yes' ) ) |
|
| 205 | + , $feedback |
|
| 206 | + ); |
|
| 207 | + |
|
| 208 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 209 | + |
|
| 210 | + // The import shouldn't have been performed. |
|
| 211 | + $this->assertEmpty( $this->importer->imports ); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Test that it skips a disabled option. |
|
| 216 | + * |
|
| 217 | + * @since 1.0.0 |
|
| 218 | + * |
|
| 219 | + * @covers WordPoints_Importer::do_import |
|
| 220 | + */ |
|
| 221 | + public function test_do_import_disabled_option() { |
|
| 222 | + |
|
| 223 | + $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
| 224 | + |
|
| 225 | + $this->importer->components['points']['user_points']['can_import'] = |
|
| 226 | + array( $this->importer, 'cant_import' ); |
|
| 227 | + |
|
| 228 | + $this->importer->do_import( |
|
| 229 | + array( 'points' => array( 'user_points' => '1' ) ) |
|
| 230 | + , $feedback |
|
| 231 | + ); |
|
| 232 | + |
|
| 233 | + $this->assertCount( 1, $this->importer->can_imports ); |
|
| 234 | + $this->assertCount( 1, $feedback->messages['warning'] ); |
|
| 235 | + |
|
| 236 | + // The import shouldn't have been performed. |
|
| 237 | + $this->assertEmpty( $this->importer->imports ); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Test that the can_import function is passed any settings. |
|
| 242 | + * |
|
| 243 | + * @since 1.0.0 |
|
| 244 | + * |
|
| 245 | + * @covers WordPoints_Importer::do_import |
|
| 246 | + */ |
|
| 247 | + public function test_do_import_can_import_passed_settings() { |
|
| 248 | + |
|
| 249 | + $this->importer->do_import( |
|
| 250 | + array( |
|
| 251 | + 'points' => array( |
|
| 252 | + 'user_points' => '1', |
|
| 253 | + '_data' => array( 'testing' => 1 ), |
|
| 254 | + ), |
|
| 255 | + ) |
|
| 256 | + , new WordPoints_Importer_Tests_Feedback() |
|
| 257 | + ); |
|
| 258 | + |
|
| 259 | + $this->assertCount( 1, $this->importer->can_imports ); |
|
| 260 | + $this->assertEquals( |
|
| 261 | + array( 'testing' => 1 ) |
|
| 262 | + , $this->importer->can_imports[0] |
|
| 263 | + ); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * Test that it calls the importer function. |
|
| 268 | + * |
|
| 269 | + * @since 1.0.0 |
|
| 270 | + * |
|
| 271 | + * @covers WordPoints_Importer::do_import |
|
| 272 | + */ |
|
| 273 | + public function test_do_import() { |
|
| 274 | + |
|
| 275 | + $this->importer->do_import( |
|
| 276 | + array( 'points' => array( 'user_points' => '1' ) ) |
|
| 277 | + , new WordPoints_Importer_Tests_Feedback() |
|
| 278 | + ); |
|
| 279 | + |
|
| 280 | + $this->assertCount( 1, $this->importer->imports ); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Test that the import function is passed any settings. |
|
| 285 | + * |
|
| 286 | + * @since 1.0.0 |
|
| 287 | + * |
|
| 288 | + * @covers WordPoints_Importer::do_import |
|
| 289 | + */ |
|
| 290 | + public function test_do_import_passed_settings() { |
|
| 291 | + |
|
| 292 | + $this->importer->do_import( |
|
| 293 | + array( |
|
| 294 | + 'points' => array( |
|
| 295 | + 'user_points' => '1', |
|
| 296 | + '_data' => array( 'testing' => 1 ), |
|
| 297 | + ), |
|
| 298 | + ) |
|
| 299 | + , new WordPoints_Importer_Tests_Feedback() |
|
| 300 | + ); |
|
| 301 | + |
|
| 302 | + $this->assertCount( 1, $this->importer->imports ); |
|
| 303 | + $this->assertEquals( |
|
| 304 | + array( 'testing' => 1 ) |
|
| 305 | + , $this->importer->imports[0] |
|
| 306 | + ); |
|
| 307 | + } |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // EOF |
@@ -16,149 +16,149 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class WordPoints_Importers_Test extends WP_UnitTestCase { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Backup of the importers when the test begins. |
|
| 21 | - * |
|
| 22 | - * @since 1.0.0 |
|
| 23 | - * |
|
| 24 | - * @var array[] |
|
| 25 | - */ |
|
| 26 | - protected $_backup_importers; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @since 1.0.0 |
|
| 30 | - */ |
|
| 31 | - public function setUp() { |
|
| 32 | - |
|
| 33 | - parent::setUp(); |
|
| 34 | - |
|
| 35 | - $this->_backup_importers = WordPoints_Importers::get(); |
|
| 36 | - |
|
| 37 | - WordPoints_Importers::register( |
|
| 38 | - 'test' |
|
| 39 | - , array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 40 | - ); |
|
| 41 | - |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - */ |
|
| 47 | - public function tearDown() { |
|
| 48 | - |
|
| 49 | - $importers = WordPoints_Importers::get(); |
|
| 50 | - |
|
| 51 | - foreach ( $this->_backup_importers as $slug => $args ) { |
|
| 52 | - |
|
| 53 | - if ( ! isset( $importers[ $slug ] ) ) { |
|
| 54 | - WordPoints_Importers::register( $slug, $args ); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - unset( $importers[ $slug ] ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - foreach ( $importers as $slug => $args ) { |
|
| 61 | - WordPoints_Importers::deregister( $slug ); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - parent::tearDown(); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Test registration. |
|
| 69 | - * |
|
| 70 | - * @since 1.0.0 |
|
| 71 | - * |
|
| 72 | - * @covers WordPoints_Importers::register |
|
| 73 | - * @covers WordPoints_Importers::get |
|
| 74 | - */ |
|
| 75 | - public function test_register() { |
|
| 76 | - |
|
| 77 | - WordPoints_Importers::register( |
|
| 78 | - __METHOD__ |
|
| 79 | - , array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 80 | - ); |
|
| 81 | - |
|
| 82 | - $importers = WordPoints_Importers::get(); |
|
| 83 | - |
|
| 84 | - $this->assertArrayHasKey( 'test', $importers ); |
|
| 85 | - $this->assertEquals( |
|
| 86 | - array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 87 | - , $importers['test'] |
|
| 88 | - ); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Test that deregister() deregisters the importer. |
|
| 93 | - * |
|
| 94 | - * @since 1.0.0 |
|
| 95 | - * |
|
| 96 | - * @covers WordPoints_Importers::register |
|
| 97 | - * @covers WordPoints_Importers::get |
|
| 98 | - */ |
|
| 99 | - public function test_deregister() { |
|
| 100 | - |
|
| 101 | - WordPoints_Importers::deregister( 'test' ); |
|
| 102 | - |
|
| 103 | - $importers = WordPoints_Importers::get(); |
|
| 104 | - |
|
| 105 | - $this->assertArrayNotHasKey( 'test', $importers ); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Test that is_registered() returns true for a registered importer. |
|
| 110 | - * |
|
| 111 | - * @since 1.0.0 |
|
| 112 | - * |
|
| 113 | - * @covers WordPoints_Importers::is_registered |
|
| 114 | - */ |
|
| 115 | - public function test_is_registered() { |
|
| 116 | - |
|
| 117 | - $this->assertTrue( WordPoints_Importers::is_registered( 'test' ) ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Test that is_registered() returns false for an unregistered importer. |
|
| 122 | - * |
|
| 123 | - * @since 1.0.0 |
|
| 124 | - * |
|
| 125 | - * @covers WordPoints_Importers::is_registered |
|
| 126 | - */ |
|
| 127 | - public function test_is_registered_unregistered() { |
|
| 128 | - |
|
| 129 | - WordPoints_Importers::deregister( 'test' ); |
|
| 130 | - |
|
| 131 | - $this->assertFalse( WordPoints_Importers::is_registered( 'test' ) ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Test that get_importer() returns false for an unregistered importer. |
|
| 136 | - * |
|
| 137 | - * @since 1.0.0 |
|
| 138 | - * |
|
| 139 | - * @covers WordPoints_Importers::get_importer |
|
| 140 | - */ |
|
| 141 | - public function test_get_unregistered_importer() { |
|
| 142 | - |
|
| 143 | - WordPoints_Importers::deregister( 'test' ); |
|
| 144 | - |
|
| 145 | - $this->assertFalse( WordPoints_Importers::get_importer( 'test' ) ); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Test that get_importer() returns an importer object. |
|
| 150 | - * |
|
| 151 | - * @since 1.0.0 |
|
| 152 | - * |
|
| 153 | - * @covers WordPoints_Importers::get_importer |
|
| 154 | - */ |
|
| 155 | - public function test_get_importer() { |
|
| 156 | - |
|
| 157 | - $this->assertInstanceOf( |
|
| 158 | - 'WordPoints_Importer_Mock' |
|
| 159 | - , WordPoints_Importers::get_importer( 'test' ) |
|
| 160 | - ); |
|
| 161 | - } |
|
| 19 | + /** |
|
| 20 | + * Backup of the importers when the test begins. |
|
| 21 | + * |
|
| 22 | + * @since 1.0.0 |
|
| 23 | + * |
|
| 24 | + * @var array[] |
|
| 25 | + */ |
|
| 26 | + protected $_backup_importers; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @since 1.0.0 |
|
| 30 | + */ |
|
| 31 | + public function setUp() { |
|
| 32 | + |
|
| 33 | + parent::setUp(); |
|
| 34 | + |
|
| 35 | + $this->_backup_importers = WordPoints_Importers::get(); |
|
| 36 | + |
|
| 37 | + WordPoints_Importers::register( |
|
| 38 | + 'test' |
|
| 39 | + , array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 40 | + ); |
|
| 41 | + |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + */ |
|
| 47 | + public function tearDown() { |
|
| 48 | + |
|
| 49 | + $importers = WordPoints_Importers::get(); |
|
| 50 | + |
|
| 51 | + foreach ( $this->_backup_importers as $slug => $args ) { |
|
| 52 | + |
|
| 53 | + if ( ! isset( $importers[ $slug ] ) ) { |
|
| 54 | + WordPoints_Importers::register( $slug, $args ); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + unset( $importers[ $slug ] ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + foreach ( $importers as $slug => $args ) { |
|
| 61 | + WordPoints_Importers::deregister( $slug ); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + parent::tearDown(); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Test registration. |
|
| 69 | + * |
|
| 70 | + * @since 1.0.0 |
|
| 71 | + * |
|
| 72 | + * @covers WordPoints_Importers::register |
|
| 73 | + * @covers WordPoints_Importers::get |
|
| 74 | + */ |
|
| 75 | + public function test_register() { |
|
| 76 | + |
|
| 77 | + WordPoints_Importers::register( |
|
| 78 | + __METHOD__ |
|
| 79 | + , array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 80 | + ); |
|
| 81 | + |
|
| 82 | + $importers = WordPoints_Importers::get(); |
|
| 83 | + |
|
| 84 | + $this->assertArrayHasKey( 'test', $importers ); |
|
| 85 | + $this->assertEquals( |
|
| 86 | + array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 87 | + , $importers['test'] |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Test that deregister() deregisters the importer. |
|
| 93 | + * |
|
| 94 | + * @since 1.0.0 |
|
| 95 | + * |
|
| 96 | + * @covers WordPoints_Importers::register |
|
| 97 | + * @covers WordPoints_Importers::get |
|
| 98 | + */ |
|
| 99 | + public function test_deregister() { |
|
| 100 | + |
|
| 101 | + WordPoints_Importers::deregister( 'test' ); |
|
| 102 | + |
|
| 103 | + $importers = WordPoints_Importers::get(); |
|
| 104 | + |
|
| 105 | + $this->assertArrayNotHasKey( 'test', $importers ); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Test that is_registered() returns true for a registered importer. |
|
| 110 | + * |
|
| 111 | + * @since 1.0.0 |
|
| 112 | + * |
|
| 113 | + * @covers WordPoints_Importers::is_registered |
|
| 114 | + */ |
|
| 115 | + public function test_is_registered() { |
|
| 116 | + |
|
| 117 | + $this->assertTrue( WordPoints_Importers::is_registered( 'test' ) ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Test that is_registered() returns false for an unregistered importer. |
|
| 122 | + * |
|
| 123 | + * @since 1.0.0 |
|
| 124 | + * |
|
| 125 | + * @covers WordPoints_Importers::is_registered |
|
| 126 | + */ |
|
| 127 | + public function test_is_registered_unregistered() { |
|
| 128 | + |
|
| 129 | + WordPoints_Importers::deregister( 'test' ); |
|
| 130 | + |
|
| 131 | + $this->assertFalse( WordPoints_Importers::is_registered( 'test' ) ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Test that get_importer() returns false for an unregistered importer. |
|
| 136 | + * |
|
| 137 | + * @since 1.0.0 |
|
| 138 | + * |
|
| 139 | + * @covers WordPoints_Importers::get_importer |
|
| 140 | + */ |
|
| 141 | + public function test_get_unregistered_importer() { |
|
| 142 | + |
|
| 143 | + WordPoints_Importers::deregister( 'test' ); |
|
| 144 | + |
|
| 145 | + $this->assertFalse( WordPoints_Importers::get_importer( 'test' ) ); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Test that get_importer() returns an importer object. |
|
| 150 | + * |
|
| 151 | + * @since 1.0.0 |
|
| 152 | + * |
|
| 153 | + * @covers WordPoints_Importers::get_importer |
|
| 154 | + */ |
|
| 155 | + public function test_get_importer() { |
|
| 156 | + |
|
| 157 | + $this->assertInstanceOf( |
|
| 158 | + 'WordPoints_Importer_Mock' |
|
| 159 | + , WordPoints_Importers::get_importer( 'test' ) |
|
| 160 | + ); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | } |
| 164 | 164 | |
@@ -14,88 +14,88 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class WordPoints_Importer_Mock extends WordPoints_Importer { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - public $components; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * The "imports" performed. |
|
| 24 | - * |
|
| 25 | - * @since 1.0.0 |
|
| 26 | - * |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - public $imports; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The "imports" for that were checked for possible performance. |
|
| 33 | - * |
|
| 34 | - * @since 1.0.0 |
|
| 35 | - * |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - public $can_imports; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Whether this importer is available. |
|
| 42 | - * |
|
| 43 | - * @since 1.0.0 |
|
| 44 | - * |
|
| 45 | - * @var true|WP_Error |
|
| 46 | - */ |
|
| 47 | - public $is_available = true; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @since 1.0.0 |
|
| 51 | - */ |
|
| 52 | - public function is_available() { |
|
| 53 | - return $this->is_available; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Mock an import method. |
|
| 58 | - * |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * |
|
| 61 | - * @param array $settings The settings for this "component". |
|
| 62 | - */ |
|
| 63 | - public function do_an_import( $settings ) { |
|
| 64 | - |
|
| 65 | - $this->imports[] = $settings; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Mock a can_import method. |
|
| 70 | - * |
|
| 71 | - * @since 1.0.0 |
|
| 72 | - * |
|
| 73 | - * @param array $settings The settings for this "component". |
|
| 74 | - * |
|
| 75 | - * @return true |
|
| 76 | - */ |
|
| 77 | - public function can_import( $settings ) { |
|
| 78 | - |
|
| 79 | - $this->can_imports[] = $settings; |
|
| 80 | - |
|
| 81 | - return true; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Return a WP_Error because we can't do the import for an option. |
|
| 86 | - * |
|
| 87 | - * @since 1.0.0 |
|
| 88 | - * |
|
| 89 | - * @param array $settings The settings for this "component". |
|
| 90 | - * |
|
| 91 | - * @return WP_Error An error. |
|
| 92 | - */ |
|
| 93 | - public function cant_import( $settings ) { |
|
| 94 | - |
|
| 95 | - $this->can_imports[] = $settings; |
|
| 96 | - |
|
| 97 | - return new WP_Error(); |
|
| 98 | - } |
|
| 17 | + /** |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + public $components; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * The "imports" performed. |
|
| 24 | + * |
|
| 25 | + * @since 1.0.0 |
|
| 26 | + * |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + public $imports; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The "imports" for that were checked for possible performance. |
|
| 33 | + * |
|
| 34 | + * @since 1.0.0 |
|
| 35 | + * |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + public $can_imports; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Whether this importer is available. |
|
| 42 | + * |
|
| 43 | + * @since 1.0.0 |
|
| 44 | + * |
|
| 45 | + * @var true|WP_Error |
|
| 46 | + */ |
|
| 47 | + public $is_available = true; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @since 1.0.0 |
|
| 51 | + */ |
|
| 52 | + public function is_available() { |
|
| 53 | + return $this->is_available; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Mock an import method. |
|
| 58 | + * |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * |
|
| 61 | + * @param array $settings The settings for this "component". |
|
| 62 | + */ |
|
| 63 | + public function do_an_import( $settings ) { |
|
| 64 | + |
|
| 65 | + $this->imports[] = $settings; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Mock a can_import method. |
|
| 70 | + * |
|
| 71 | + * @since 1.0.0 |
|
| 72 | + * |
|
| 73 | + * @param array $settings The settings for this "component". |
|
| 74 | + * |
|
| 75 | + * @return true |
|
| 76 | + */ |
|
| 77 | + public function can_import( $settings ) { |
|
| 78 | + |
|
| 79 | + $this->can_imports[] = $settings; |
|
| 80 | + |
|
| 81 | + return true; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Return a WP_Error because we can't do the import for an option. |
|
| 86 | + * |
|
| 87 | + * @since 1.0.0 |
|
| 88 | + * |
|
| 89 | + * @param array $settings The settings for this "component". |
|
| 90 | + * |
|
| 91 | + * @return WP_Error An error. |
|
| 92 | + */ |
|
| 93 | + public function cant_import( $settings ) { |
|
| 94 | + |
|
| 95 | + $this->can_imports[] = $settings; |
|
| 96 | + |
|
| 97 | + return new WP_Error(); |
|
| 98 | + } |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // EOF |
@@ -14,22 +14,22 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class WordPoints_Importer_Tests_Feedback extends WordPoints_Importer_Feedback { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * The messages that have been reported. |
|
| 19 | - * |
|
| 20 | - * @since 1.0.0 |
|
| 21 | - * |
|
| 22 | - * @var string[][] |
|
| 23 | - */ |
|
| 24 | - public $messages; |
|
| 17 | + /** |
|
| 18 | + * The messages that have been reported. |
|
| 19 | + * |
|
| 20 | + * @since 1.0.0 |
|
| 21 | + * |
|
| 22 | + * @var string[][] |
|
| 23 | + */ |
|
| 24 | + public $messages; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @since 1.0.0 |
|
| 28 | - */ |
|
| 29 | - protected function _send( $message, $type = 'info' ) { |
|
| 26 | + /** |
|
| 27 | + * @since 1.0.0 |
|
| 28 | + */ |
|
| 29 | + protected function _send( $message, $type = 'info' ) { |
|
| 30 | 30 | |
| 31 | - $this->messages[ $type ][] = $message; |
|
| 32 | - } |
|
| 31 | + $this->messages[ $type ][] = $message; |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // EOF |