Skip to content

Commit 10907d9

Browse files
authored
Merge pull request #391 from lloc/version-2.9.2
Tests added
2 parents b9d7a63 + 218ecea commit 10907d9

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

Diff for: includes/MslsMetaBox.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function render_option( int $post_id, ?int $msls_id ): string {
273273
return wp_kses(
274274
sprintf(
275275
'<option value="%d" %s>%s</option>',
276-
esc_attr( $post_id ),
276+
esc_attr( strval( $post_id ) ),
277277
selected( $post_id, $msls_id, false ),
278278
get_the_title( $post_id )
279279
),

Diff for: phpunit.xml

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44
bootstrap="tests/phpunit/bootstrap.php"
55
backupGlobals="true"
66
colors="true"
7+
testdox="false"
8+
displayDetailsOnIncompleteTests="true"
9+
displayDetailsOnSkippedTests="true"
10+
displayDetailsOnTestsThatTriggerDeprecations="true"
11+
displayDetailsOnTestsThatTriggerErrors="true"
12+
displayDetailsOnTestsThatTriggerNotices="true"
713
displayDetailsOnTestsThatTriggerWarnings="true"
8-
cacheDirectory=".phpunit.cache">
14+
displayDetailsOnPhpunitDeprecations="true"
15+
cacheDirectory=".phpunit.cache"
16+
>
917
<php>
1018
<const name="MSLS_PLUGIN_PATH" value="multisite-language-switcher/MultisiteLanguageSwitcher.php"/>
1119
<const name="MSLS_PLUGIN__FILE__" value="/var/www/html/wp-content/plugins/multisite-language-switcher/MultisiteLanguageSwitcher.php"/>

Diff for: tests/phpunit/ContentImport/TestAttachmentPathFinder.php

+29
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,33 @@ public function test_filter_srcset( $source, $imageSrc, $attachmentId, $expected
4444

4545
$this->assertEquals( $expected, $this->test->filter_srcset( $source, null, $imageSrc, null, $attachmentId ) );
4646
}
47+
48+
public static function dataprovider_filter_attachement_url(): array {
49+
$generic_obj = (object) array( 'guid' => 'http://example.com/image.jpg' );
50+
51+
$post_mock = \Mockery::mock( '\WP_Post' );
52+
$post_mock->guid = 'http://example.com/image.jpg';
53+
54+
return array(
55+
array( 'http://example.com/image.jpg', $generic_obj, 42 ),
56+
array( 'http://example.com/image.jpg', $generic_obj, 0 ),
57+
array( 'http://example.com/image.jpg', $post_mock, 42 ),
58+
);
59+
}
60+
61+
/**
62+
* @dataProvider dataprovider_filter_attachement_url
63+
*/
64+
public function test_filter_attachment_url( string $image_src, $source_post, int $attachment_id ): void {
65+
$msls_imported = array(
66+
'blog' => 1,
67+
'post' => 1,
68+
);
69+
70+
Functions\expect( 'get_post_meta' )->zeroOrMoreTimes()->andReturn( $msls_imported );
71+
Functions\expect( 'delete_post_meta' )->zeroOrMoreTimes();
72+
Functions\expect( 'get_blog_post' )->zeroOrMoreTimes()->andReturn( $source_post );
73+
74+
$this->assertEquals( $source_post->guid, $this->test->filter_attachment_url( $image_src, $attachment_id ) );
75+
}
4776
}

0 commit comments

Comments
 (0)