<commit_before><?php

/**
 * @copyright 2017 <NAME>
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
 */

namespace allejo\stakx\Test;

use allejo\stakx\Core\StakxLogger;
use allejo\stakx\Manager\CollectionManager;
use allejo\stakx\System\Filesystem;
use allejo\stakx\System\Folder;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use org\bovigo\vfs\vfsStreamFile;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Yaml\Yaml;

abstract class PHPUnit_Stakx_TestCase extends \PHPUnit_Framework_TestCase
{
    const FM_OBJ_TEMPLATE = "---\n%s\n---\n\n%s";

    /** @var string */
    protected $assetFolder;

    /**
     * @var vfsStreamFile
     */
    protected $dummyFile;

    /**
     * @var vfsStreamDirectory
     */
    protected $rootDir;

    /**
     * @var Filesystem
     */
    protected $fs;

    public function setUp()
    {
        $this->dummyFile = vfsStream::newFile('stakx.html.twig');
        $this->rootDir = vfsStream::setup();
        $this->fs = new Filesystem();

        // Inspect the VFS as an array
        // vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure();
    }

    ///
    // Assertion functions
    ///

    protected function assertStringContains($needle, $haystack, $message = '')
    {
        $this->assertNotFalse(strpos($haystack, $needle), $message);
    }

    protected function assertFileContains($fileContent, $filePath, $message = '')
    {
        (substr($filePath, -1, 1) == '/') && $filePath .= 'index.html';

        $contents = file_get_contents($filePath);

        $this->assertStringContains($fileContent, $contents, $message);
    }

    ///
    // Utility Functions
    ///

    protected function bookCollectionProvider($jailed = false)
    {
        $cm = new CollectionManager();<commit_msg>Fix unit tests to default to "build" mode<commit_after><?php

/**
 * @copyright 2017 <NAME>
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
 */

namespace allejo\stakx\Test;

use allejo\stakx\Command\BuildableCommand;
use allejo\stakx\Core\StakxLogger;
use allejo\stakx\Manager\CollectionManager;
use allejo\stakx\Service;
use allejo\stakx\System\Filesystem;
use allejo\stakx\System\Folder;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use org\bovigo\vfs\vfsStreamFile;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Yaml\Yaml;

abstract class PHPUnit_Stakx_TestCase extends \PHPUnit_Framework_TestCase
{
    const FM_OBJ_TEMPLATE = "---\n%s\n---\n\n%s";

    /** @var string */
    protected $assetFolder;

    /**
     * @var vfsStreamFile
     */
    protected $dummyFile;

    /**
     * @var vfsStreamDirectory
     */
    protected $rootDir;

    /**
     * @var Filesystem
     */
    protected $fs;

    public function setUp()
    {
        $this->dummyFile = vfsStream::newFile('stakx.html.twig');
        $this->rootDir = vfsStream::setup();
        $this->fs = new Filesystem();

        Service::setParameter(BuildableCommand::WATCHING, false);

        // Inspect the VFS as an array
        // vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure();
    }

    ///
    // Assertion functions
    ///

    protected function assertStringContains($needle, $haystack, $message = '')
    {
        $this->assertNotFalse(strpos($haystack, $needle), $message);
    }

    protected function assertFileContains($fileContent, $filePath, $message = '')
    {
        (substr($filePath, -1, 1) == '/') && $filePath .= 'index.html';

        $contents = file_get_contents($filePath);

        $this->assertStringContains($fileContent, $contents, $message);
    }

    ///
    // Utility Functions
    ///

    protected function bookCollectionProvider($jailed = false)
    {
        $cm = new CollectionManager();
{'fraction_non_alphanumeric': 0.1436251920122888, 'fraction_numerical': 0.0030721966205837174, 'mean_word_length': 2.9544534412955468, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5038595', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1254, 'n_words': 222}