PHP code example of jdgrimes / wp-filesystem-mock

1. Go to this page and download the library: Download jdgrimes/wp-filesystem-mock library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jdgrimes / wp-filesystem-mock example snippets


		/**
		 * WordPress's base filesystem API class.
		 *
		 * We need to make sure this is loaded before we can load the mock.
		 */
		system-mock/src/wp-filesystem-mock.php' );

		/**
		 * The mock filesystem class.
		 */
		

		// Creating a new mock filesystem.
		// We assign it to a member property so we can access it later.
		$this->mock_fs = new WP_Mock_Filesystem;
		
		// Create the /wp-content directory.
		// This part is optional, and you'll do more or less setup here depending on
		// what you are testing.
		$this->mock_fs->mkdir_p( WP_CONTENT_DIR );

		// Tell the WordPress filesystem API shim to use this mock filesystem.
		WP_Filesystem_Mock::set_mock( $this->mock_fs );
		
		// Tell the shim to start overriding whatever other filesystem access method
		// is in use.
		WP_Filesystem_Mock::start();
	
		// Set up the $wp_filesystem global, if the code being tested doesn't do this.
		WP_Filesystem();