-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Code and Improve Test Cases
### Changed - Refactored test cases.
- Loading branch information
Showing
3 changed files
with
39 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
<?php | ||
/** | ||
* The PHPUnit Tests for the WP_Filesystem_Utility class | ||
* | ||
* This file adds test cases for the WP_Filesystem_Utility class. | ||
* This file includes: | ||
* - Strict Typing declaration, | ||
* - Definition of WP_Filesystem_UtilityTest, | ||
* - One testcase method for the Base64 Encoded Method of the WP_Filesystem_Utility class. | ||
* | ||
* @link https://site.tld | ||
* @since 1.0.0 Introduced on 2023-08-01 15:30 | ||
* @package Plugins\PluginName\Tests | ||
* @author Your Name <[email protected]> | ||
*/ | ||
|
||
/** | ||
* Declare strict typing | ||
* | ||
* @see https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict | ||
*/ | ||
declare( strict_types = 1 ); | ||
|
||
namespace Company\Plugins\PluginName\Tests; | ||
|
||
|
@@ -7,24 +28,22 @@ | |
|
||
class WP_Filesystem_UtilityTest extends TestCase { | ||
|
||
public function testGetBase64EncodedContents() { | ||
$filesystemUtility = new WP_Filesystem_Utility(); | ||
public function testGetBase64EncodedContents() { | ||
$filesystemUtility = new WP_Filesystem_Utility(); | ||
|
||
// Replace with the actual path to the SVG file you want to test | ||
$svgFilePath = __DIR__ . '/../src/public/icons/cpt-icon.svg'; | ||
// Replace with the actual path to the SVG file you want to test | ||
$svgFilePath = __DIR__ . '/../src/public/icons/cpt-icon.svg'; | ||
|
||
// Ensure that the file exists before testing | ||
$this->assertFileExists($svgFilePath); | ||
// Ensure that the file exists before testing | ||
$this->assertFileExists( $svgFilePath ); | ||
|
||
// Get the expected base64 encoded content | ||
$expectedBase64Content = base64_encode(file_get_contents($svgFilePath)); | ||
// Get the expected base64 encoded content | ||
$expectedBase64Content = base64_encode( file_get_contents( $svgFilePath ) ); | ||
|
||
// Call the method to get base64 encoded content | ||
$actualBase64Content = $filesystemUtility->get_base64_encoded_contents($svgFilePath); | ||
// Call the method to get base64 encoded content | ||
$actualBase64Content = $filesystemUtility->get_base64_encoded_contents( $svgFilePath ); | ||
|
||
// Check if the actual content matches the expected content | ||
$this->assertEquals($expectedBase64Content, $actualBase64Content); | ||
} | ||
|
||
// Add more test cases as needed for other methods/functions in WP_Filesystem_Utility | ||
// Check if the actual content matches the expected content | ||
$this->assertEquals( $expectedBase64Content, $actualBase64Content ); | ||
} | ||
} |