src/Codeception/Module/WPFilesystem.php
public function haveTheme(
        $folder,
        $indexFileCode,
        $functionsFileCode = null
    ) {
        $dir = $this->config['themes'] . Utils::untrailslashit(Utils::unleadslashit($folder));
        $styleFile = $dir . DIRECTORY_SEPARATOR . 'style.css';
        $indexFile = $dir . DIRECTORY_SEPARATOR . 'index.php';
        $functionsFile = $dir . DIRECTORY_SEPARATOR . 'functions.php';

        if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$dir}] theme folder."
            );
        }
        $indexFileCode = $this->removeOpeningPhpTag($indexFileCode);
        $functionsFileCode = $this->removeOpeningPhpTag($functionsFileCode);
        $name = $folder;
        $style = <<<CSS
/*
Theme Name: $name
Author: wp-browser
Description: $name
Version: 1.0
*/
CSS;
        $stylePut = file_put_contents($styleFile, $style);

        if (!$stylePut) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$styleFile}] theme file."
            );
        }

        $this->toClean[] = $dir;

        $index = '<?php ' . $indexFileCode;

        $indexPut = file_put_contents($indexFile, $index);

        if (!$indexPut) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$indexFile}] theme file."
            );
        }

        if (null !== $functionsFileCode) {
            $functions = '<?php ' . $functionsFileCode;

            $functionsPut = file_put_contents($functionsFile, $functions);

            if (!$functionsPut) {
                throw new ModuleException(
                    __CLASS__,
                    "Could not create [{$indexFile}] theme file."
                );
            }
        }
    }
public function haveTheme(
        $folder,
        $indexFileCode,
        $functionsFileCode = null
    ) {
        $dir = $this->config['themes'] . Utils::untrailslashit(Utils::unleadslashit($folder));
        $styleFile = $dir . DIRECTORY_SEPARATOR . 'style.css';
        $indexFile = $dir . DIRECTORY_SEPARATOR . 'index.php';
        $functionsFile = $dir . DIRECTORY_SEPARATOR . 'functions.php';

        if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$dir}] theme folder."
            );
        }
        $indexFileCode = $this->removeOpeningPhpTag($indexFileCode);
        $functionsFileCode = $this->removeOpeningPhpTag($functionsFileCode);
        $name = $folder;
        $style = <<<CSS
/*
Theme Name: $name
Author: wp-browser
Description: $name
Version: 1.0
*/
CSS;
        $stylePut = file_put_contents($styleFile, $style);

        if (!$stylePut) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$styleFile}] theme file."
            );
        }

        $this->toClean[] = $dir;

        $index = '<?php ' . $indexFileCode;

        $indexPut = file_put_contents($indexFile, $index);

        if (!$indexPut) {
            throw new ModuleException(
                __CLASS__,
                "Could not create [{$indexFile}] theme file."
            );
        }

        if (null !== $functionsFileCode) {
            $functions = '<?php ' . $functionsFileCode;

            $functionsPut = file_put_contents($functionsFile, $functions);

            if (!$functionsPut) {
                throw new ModuleException(
                    __CLASS__,
                    "Could not create [{$indexFile}] theme file."
                );
            }
        }
    }
public function haveTheme ( $ folder , $ indexFileCode , $ functionsFileCode = null ) { $ dir = $ this -> config [ 'themes' ] . Utils :: untrailslashit ( Utils :: unleadslashit ( $ folder ) ) ; $ styleFile = $ dir . DIRECTORY_SEPARATOR . 'style.css' ; $ indexFile = $ dir . DIRECTORY_SEPARATOR . 'index.php' ; $ functionsFile = $ dir . DIRECTORY_SEPARATOR . 'functions.php' ; if ( ! @ mkdir ( $ dir , 0777 , true ) && ! is_dir ( $ dir ) ) { throw new ModuleException ( __CLASS__ , "Could not create [{$dir}] theme folder." ) ; } $ indexFileCode = $ this -> removeOpeningPhpTag ( $ indexFileCode ) ; $ functionsFileCode = $ this -> removeOpeningPhpTag ( $ functionsFileCode ) ; $ name = $ folder ; $ style =  <<<CSS
/*
Theme Name: $name
Author: wp-browser
Description: $name
Version: 1.0
*/
CSS ; $ stylePut = file_put_contents ( $ styleFile , $ style ) ; if ( ! $ stylePut ) { throw new ModuleException ( __CLASS__ , "Could not create [{$styleFile}] theme file." ) ; } $ this -> toClean [ ] = $ dir ; $ index = '<?php ' . $ indexFileCode ; $ indexPut = file_put_contents ( $ indexFile , $ index ) ; if ( ! $ indexPut ) { throw new ModuleException ( __CLASS__ , "Could not create [{$indexFile}] theme file." ) ; } if ( null !== $ functionsFileCode ) { $ functions = '<?php ' . $ functionsFileCode ; $ functionsPut = file_put_contents ( $ functionsFile , $ functions ) ; if ( ! $ functionsPut ) { throw new ModuleException ( __CLASS__ , "Could not create [{$indexFile}] theme file." ) ; } } }
Creates a theme file structure, including theme style file and index, in the themes folder.

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

@example
``` php
$code = 'sayHi();';
$functionsCode  = 'function sayHi(){echo "Hello world";};';
$I->haveTheme('foo', $indexCode, $functionsCode);
// Load the code from a file.
$indexCode = file_get_contents(codecept_data_dir('code/index.php'));
$functionsCode = file_get_contents(codecept_data_dir('code/functions.php'));
$I->haveTheme('foo', $indexCode, $functionsCode);
```

@param string $folder            The path to the theme to create, relative to the themes root folder.
@param string $indexFileCode     The content of the theme index.php file with or without the opening PHP tag.
@param string $functionsFileCode The content of the theme functions.php file with or without the opening PHP tag.

@throws \Codeception\Exception\ModuleException If the mu-plugin folder and/or files could not be created.
Creates a theme file structure including theme style file and index in the themes folder .