<commit_before><?php declare(strict_types=1);

/*
 * This file is part of Pharaoh.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Pharaoh\Tests;

use Pharaoh\Config\ConfigInterface;
use Pharaoh\Tests\Fixtures\PharaohForTest;

/**
 * @coversDefaultClass \Pharaoh\Pharaoh
 */
class PharaohTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @covers ::__construct
     */
    public function testConstructor()
    {
        $profile = true;
        $name    = 'PharaohTest';
        $config  = $this->createMock(ConfigInterface::class);

        $pharaoh = new PharaohForTest($config, $name, $profile);

        $this->assertEquals($profile, $pharaoh->isProfilerEnabled());
        $this->assertFalse($pharaoh->isBooted());
        $this->assertLessThanOrEqual(microtime(true), $pharaoh->getStartTime());
    }

    /**
     * @covers ::__clone
     */
    public function testClone()
    {
        $profile = true;
        $name    = 'PharaohTest';
        $config  = $this->createMock(ConfigInterface::class);

        $pharaoh = new PharaohForTest($config, $name, $profile);

        $clone = clone $pharaoh;

        $this->assertEquals($profile, $clone->isProfilerEnabled());
        $this->assertFalse($clone->isBooted());
        $this->assertLessThanOrEqual(microtime(true), $clone->getStartTime());
        $this->assertLessThan($clone->getStartTime(), $pharaoh->getStartTime());
    }

    /**
     * @covers ::getConfigDirectory
     */
    public function testGetConfigDirectory()
    {
        $profile = true;
        $name    = 'PharaohTest';
        $config  = $this->createMock(ConfigInterface::class);

        $configDir = 'ConfigDirectory';

        $config
            ->expects($this->once())
            ->method('getConfigDirectory')
            ->will($this->returnValue($configDir))
        ;

        $pharaoh = new PharaohForTest($config, $name, $profile);

        $this->assertEquals($configDir, $pharaoh->getConfigDirectory());
    }

    /**<commit_msg>be more strict about microtime floating point precision comparison<commit_after><?php declare(strict_types=1);

/*
 * This file is part of Pharaoh.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Pharaoh\Tests;

use Pharaoh\Config\ConfigInterface;
use Pharaoh\Tests\Fixtures\PharaohForTest;

/**
 * @coversDefaultClass \Pharaoh\Pharaoh
 */
class PharaohTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @covers ::__construct
     */
    public function testConstructor()
    {
        $profile = true;
        $name    = 'PharaohTest';
        $config  = $this->createMock(ConfigInterface::class);

        $pharaoh = new PharaohForTest($config, $name, $profile);

        $this->assertEquals($profile, $pharaoh->isProfilerEnabled());
        $this->assertFalse($pharaoh->isBooted());
        $this->assertLessThan(microtime(true), $pharaoh->getStartTime());
    }

    /**
     * @covers ::__clone
     */
    public function testClone()
    {
        $profile = true;
        $name    = 'PharaohTest';
        $config  = $this->createMock(ConfigInterface::class);

        $pharaoh = new PharaohForTest($config, $name, $profile);

        $clone = clone $pharaoh;

        $this->assertEquals($profile, $clone->isProfilerEnabled());
        $this->assertFalse($clone->isBooted());
        $this->assertLessThan(microtime(true), $clone->getStartTime());
        $this->assertLessThan($clone->getStartTime(), $pharaoh->getStartTime());
    }

    /**
     * @covers ::getConfigDirectory
     */
    public function testGetConfigDirectory()
    {
        $profile = true;
        $name    = 'PharaohTest';
        $config  = $this->createMock(ConfigInterface::class);

        $configDir = 'ConfigDirectory';

        $config
            ->expects($this->once())
            ->method('getConfigDirectory')
            ->will($this->returnValue($configDir))
        ;

        $pharaoh = new PharaohForTest($config, $name, $profile);

        $this->assertEquals($configDir, $pharaoh->getConfigDirectory());
    }

    /**
{'fraction_non_alphanumeric': 0.14912075029308325, 'fraction_numerical': 0.0004689331770222743, 'mean_word_length': 2.8536585365853657, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 59, 'https://': 0, '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': '6473233', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1225, 'n_words': 234}