mirror of
git://develop.git.wordpress.org/
synced 2025-02-07 08:04:27 +01:00
Build/Test Tools: Add tests coverage for _wp_check_alternate_file_names()
.
This changeset adds missing unit tests for this function. Props pbearne, costdev, peterwilsoncc. Fixes #55199. git-svn-id: https://develop.svn.wordpress.org/trunk@54422 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d53d13d6ce
commit
ec7a7c3f16
68
tests/phpunit/tests/functions/wpCheckAlternateFileNames.php
Normal file
68
tests/phpunit/tests/functions/wpCheckAlternateFileNames.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group functions.php
|
||||
* @covers ::_wp_check_alternate_file_names
|
||||
*/
|
||||
class Tests_Functions_WpCheckAlternateFileNames extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider data_wp_check_alternate_file_names
|
||||
*
|
||||
* @ticket 55199
|
||||
*
|
||||
* @param array $filenames Array of filenames to check.
|
||||
* @param string $dir The directory to check.
|
||||
* @param array $files An array of existing files in the directory.
|
||||
* @param bool $expected Expected result.
|
||||
*/
|
||||
public function test_wp_check_alternate_file_names( $filenames, $dir, $files, $expected ) {
|
||||
$this->assertSame( $expected, _wp_check_alternate_file_names( $filenames, $dir, $files ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function data_wp_check_alternate_file_names() {
|
||||
return array(
|
||||
'an existing file' => array(
|
||||
'filenames' => array( 'canola.jpg' ),
|
||||
'dir' => DIR_TESTDATA . '/images/',
|
||||
'files' => array(),
|
||||
'expected' => true,
|
||||
),
|
||||
'multiple existing files' => array(
|
||||
'filenames' => array( 'canola.jpg', 'codeispoetry.png' ),
|
||||
'dir' => DIR_TESTDATA . '/images/',
|
||||
'files' => array(),
|
||||
'expected' => true,
|
||||
),
|
||||
'a non-existent file and an existing file' => array(
|
||||
'filenames' => array( 'an-image.jpg', 'codeispoetry.png' ),
|
||||
'dir' => DIR_TESTDATA . '/images/',
|
||||
'files' => array(),
|
||||
'expected' => true,
|
||||
),
|
||||
'a non-existent file and an existing image sub-size file' => array(
|
||||
'filenames' => array( 'one-blue-pixel.png' ),
|
||||
'dir' => DIR_TESTDATA . '/images/',
|
||||
'files' => array( 'one-blue-pixel-100x100.png' ),
|
||||
'expected' => true,
|
||||
),
|
||||
'a non-existent file and no other existing files' => array(
|
||||
'filenames' => array( 'filename.php' ),
|
||||
'dir' => DIR_TESTDATA . '/images/',
|
||||
'files' => array(),
|
||||
'expected' => false,
|
||||
),
|
||||
'multiple non-existent files and no existing image sub-size files' => array(
|
||||
'filenames' => array( 'canola.jpg', 'codeispoetry.png' ),
|
||||
'dir' => DIR_TESTDATA . '/functions/',
|
||||
'files' => array( 'an-image-100x100.jpg', 'another-image-100x100.png' ),
|
||||
'expected' => false,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user