src/Codeception/Module/WPFilesystem.php
public function havePlugin($path, $code)
    {
        $fullPath = $this->config['plugins'] . Utils::unleadslashit($path);
        $dir = dirname($fullPath);
        if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$dir}] plugin folder."
            );
        }
        $slug = basename(dirname($path));
        $code = $this->removeOpeningPhpTag($code);
        $name = $slug;
        $contents = <<<PHP
<?php
/*
Plugin Name: $name
Description: $name
*/

$code
PHP;

        $put = file_put_contents($fullPath, $contents);

        if (!$put) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$fullPath}] plugin file."
            );
        }

        $this->toClean[] = $dir;
    }
public function havePlugin($path, $code)
    {
        $fullPath = $this->config['plugins'] . Utils::unleadslashit($path);
        $dir = dirname($fullPath);
        if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$dir}] plugin folder."
            );
        }
        $slug = basename(dirname($path));
        $code = $this->removeOpeningPhpTag($code);
        $name = $slug;
        $contents = <<<PHP
<?php
/*
Plugin Name: $name
Description: $name
*/

$code
PHP;

        $put = file_put_contents($fullPath, $contents);

        if (!$put) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$fullPath}] plugin file."
            );
        }

        $this->toClean[] = $dir;
    }
public function havePlugin ( $ path , $ code ) { $ fullPath = $ this -> config [ 'plugins' ] . Utils :: unleadslashit ( $ path ) ; $ dir = dirname ( $ fullPath ) ; if ( ! @ mkdir ( $ dir , 0777 , true ) && ! is_dir ( $ dir ) ) { throw new ModuleException ( __CLASS__ , "Could not create [{$dir}] plugin folder." ) ; } $ slug = basename ( dirname ( $ path ) ) ; $ code = $ this -> removeOpeningPhpTag ( $ code ) ; $ name = $ slug ; $ contents =  <<<PHP
<?php
/*
Plugin Name: $name
Description: $name
*/

$code
PHP ; $ put = file_put_contents ( $ fullPath , $ contents ) ; if ( ! $ put ) { throw new ModuleException ( __CLASS__ , "Could not create [{$fullPath}] plugin file." ) ; } $ this -> toClean [ ] = $ dir ; }
Creates a plugin file, including plugin header, in the plugins folder.

The plugin is just created and not activated; the code can not contain the opening '<?php' tag.

@example
``` php
$code = 'echo "Hello world!"';
$I->havePlugin('foo/plugin.php', $code);
// Load the code from a file.
$code = file_get_contents(codecept_data_dir('code/plugin.php'));
$I->havePlugin('foo/plugin.php', $code);
```

@param string $path The path to the file to create, relative to the plugins folder.
@param string $code The content of the plugin file with or without the opening PHP tag.

@throws \Codeception\Exception\ModuleException If the plugin folder and/or files could not be created.
Creates a plugin file including plugin header in the plugins folder .