<commit_before><?php
/**
 * Opulence
 *
 * @link      https://www.opulencephp.com
 * @copyright Copyright (C) 2016 <NAME>
 * @license   https://github.com/opulencephp/opulencephp.com/blob/master/LICENSE.md
 */
namespace OpulenceWebsite\Application\Http;

use Opulence\Files\FileSystem;
use OpulenceWebsite\Domain\Documentation\Documentation;
use Parsedown;

/**
 * Defines the page tests
 */
class PageTest extends IntegrationTestCase
{
    /** @var Documentation The docs */
    private $docs = null;

    /**
     * Sets up the tests
     */
    public function setUp()
    {
        parent::setUp();

        $paths = require __DIR__ . "/../../../../../config/paths.php";
        $this->docs = new Documentation(
            require "{$paths["config"]}/documentation.php",
            $this->createMock(Parsedown::class),
            $paths,
            $this->createMock(FileSystem::class)
        );
    }

    /**
     * Tests that the 404 template is set up correctly
     */
    public function test404PageIsSetUpCorrectly()
    {
        $this->get("/does-not-exist")
            ->go()
            ->assertResponse
            ->isNotFound();
    }

    /**
     * Tests that the docs template is set up correctly
     */
    public function testDocsPageIsSetUpCorrectly()
    {
        $this->get("/docs")
            ->go()
            ->assertResponse
            ->isOK();
        $this->assertView
            ->varEquals("doFormatTitle", true)
            ->varEquals("mainClasses", "docs")
            ->varEquals("docs", $this->docs->getDocs(Documentation::DEFAULT_BRANCH))
            ->varEquals("mainClasses", "docs");
        $this->checkMasterTemplateSetup();
    }

    /**
     * Tests that the home template is set up correctly
     */
    public function testHomePageIsSetUpCorrectly()
    {
        $this->get("/")
            ->go()
            ->assertResponse
            ->isOK();
        $this->assertView
            ->varEquals("doFormatTitle", false)
            ->varEquals("title", "Opulence | PHP Framework")
            ->varEquals("metaKeywords", ["opulence", "php", "framework", "orm", "router", "console", "mvc"])
            ->varEquals("metaDescription", "A simple, secure, and scalable MVC framework for PHP 7")
            ->varEquals("mainClasses", "home");
        $this->checkMasterTemplateSetup();
    }

    /**
     * Tests that a non-existent doc redirects to the default
     */
    public function testNonExistentDocIsRedirectingToDefault()
    {
        $this->get("/docs/master/does-not-exist")
            ->go()
            ->assertResponse
            ->redirectsTo("/docs/master/" . $this->docs->getDefaultDoc("master"));
    }

    /**
     * Tests that a non-existent doc version redirects to the default
     */
    public function testNonExistentDocVersionIsRedirectingToDefault()
    {
        $this->get("/docs/non-existent-version/does-not-exist")
            ->go()
            ->assertResponse
            ->redirectsTo("/docs");
    }

    /**
     * Tests that the master template is set up correctly
     */
    private function checkMasterTemplateSetup()
    {
        $this->assertView
            ->varEquals("masterCSS", [
                "/assets/css/style.css?v=1.9",
                "/assets/css/prism.css",
                "//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"
            ])
            ->varEquals("javaScript", [
                "/assets/js/prism.js"
            ])
            ->varEquals("defaultBranch", Documentation::DEFAULT_BRANCH);
    }
}<commit_msg>Fixed test<commit_after><?php
/**
 * Opulence
 *
 * @link      https://www.opulencephp.com
 * @copyright Copyright (C) 2016 <NAME>
 * @license   https://github.com/opulencephp/opulencephp.com/blob/master/LICENSE.md
 */
namespace OpulenceWebsite\Application\Http;

use Opulence\Files\FileSystem;
use OpulenceWebsite\Domain\Documentation\Documentation;
use Parsedown;

/**
 * Defines the page tests
 */
class PageTest extends IntegrationTestCase
{
    /** @var Documentation The docs */
    private $docs = null;

    /**
     * Sets up the tests
     */
    public function setUp()
    {
        parent::setUp();

        $paths = require __DIR__ . "/../../../../../config/paths.php";
        $this->docs = new Documentation(
            require "{$paths["config"]}/documentation.php",
            $this->createMock(Parsedown::class),
            $paths,
            $this->createMock(FileSystem::class)
        );
    }

    /**
     * Tests that the 404 template is set up correctly
     */
    public function test404PageIsSetUpCorrectly()
    {
        $this->get("/does-not-exist")
            ->go()
            ->assertResponse
            ->isNotFound();
    }

    /**
     * Tests that the docs template is set up correctly
     */
    public function testDocsPageIsSetUpCorrectly()
    {
        $this->get("/docs")
            ->go()
            ->assertResponse
            ->isOK();
        $this->assertView
            ->varEquals("doFormatTitle", true)
            ->varEquals("mainClasses", "docs")
            ->varEquals("docs", $this->docs->getDocs(Documentation::DEFAULT_BRANCH))
            ->varEquals("mainClasses", "docs");
        $this->checkMasterTemplateSetup();
    }

    /**
     * Tests that the home template is set up correctly
     */
    public function testHomePageIsSetUpCorrectly()
    {
        $this->get("/")
            ->go()
            ->assertResponse
            ->isOK();
        $this->assertView
            ->varEquals("doFormatTitle", false)
            ->varEquals("title", "Opulence | PHP Framework")
            ->varEquals("metaKeywords", ["opulence", "php", "framework", "orm", "router", "console", "mvc"])
            ->varEquals("metaDescription", "A simple, secure, and scalable MVC framework for PHP 7")
            ->varEquals("mainClasses", "home");
        $this->checkMasterTemplateSetup();
    }

    /**
     * Tests that a non-existent doc redirects to the default
     */
    public function testNonExistentDocIsRedirectingToDefault()
    {
        $this->get("/docs/master/does-not-exist")
            ->go()
            ->assertResponse
            ->redirectsTo("/docs/master/" . $this->docs->getDefaultDoc("master"));
    }

    /**
     * Tests that a non-existent doc version redirects to the default
     */
    public function testNonExistentDocVersionIsRedirectingToDefault()
    {
        $this->get("/docs/non-existent-version/does-not-exist")
            ->go()
            ->assertResponse
            ->redirectsTo("/docs");
    }

    /**
     * Tests that the master template is set up correctly
     */
    private function checkMasterTemplateSetup()
    {
        $this->assertView
            ->varEquals("masterCSS", [
                "/assets/css/style.css?v=1.10",
                "/assets/css/prism.css",
                "//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"
            ])
            ->varEquals("javaScript", [
                "/assets/js/prism.js"
            ])
            ->varEquals("defaultBranch", Documentation::DEFAULT_BRANCH);
    }
}
{'fraction_non_alphanumeric': 0.14681208053691275, 'fraction_numerical': 0.004614093959731544, 'mean_word_length': 1.9804166666666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 93, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '4226423', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1972, 'n_words': 393}