<commit_before><?php

/*
 * HTML Server Components addon for Bear Framework
 * https://github.com/ivopetkov/html-server-components-bearframework-addon
 * Copyright (c) 2016 <NAME>
 * Free to use under the MIT license.
 */

/**
 * @runTestsInSeparateProcesses
 */
class ComponentsTest extends BearFrameworkAddonTestCase
{

    /**
     * 
     */
    public function testProccess()
    {
        $app = $this->getApp();

        $content = '<!DOCTYPE html><html><head></head><body>content</body></html>';
        $result = $app->components->process('<component src="data:base64,' . base64_encode($content) . '"></component>');
        $this->assertTrue($result === $content);
    }

    /**
     * 
     */
    public function testAlias()
    {
        $app = $this->getApp();

        $content = '<!DOCTYPE html><html><head></head><body>content</body></html>';
        $app->components->addAlias('newContent', 'data:base64,' . base64_encode($content));
        $result = $app->components->process('<component src="newContent" />');
        $this->assertTrue($result === $content);
    }

    /**
     * 
     */
    public function testFile()
    {
        $app = $this->getApp();

        $this->createFile($app->config->appDir . '/component1.php', '<!DOCTYPE html><html><head></head><body>content1<component src="file:' . $app->config->appDir . '/component2.php" /></body></html>');
        $this->createFile($app->config->appDir . '/component2.php', '<!DOCTYPE html><html><head></head><body>content2</body></html>');

        $result = $app->components->process('<component src="file:' . $app->config->appDir . '/component1.php" />');
        $this->assertTrue($result === '<!DOCTYPE html><html><head></head><body>content1content2</body></html>');
    }

    /**
     * 
     */
    public function testInvalidArguments1()
    {
        $app = $this->getApp();<commit_msg>Tests update.<commit_after><?php

/*
 * HTML Server Components addon for Bear Framework
 * https://github.com/ivopetkov/html-server-components-bearframework-addon
 * Copyright (c) 2016 <NAME>
 * Free to use under the MIT license.
 */

/**
 * @runTestsInSeparateProcesses
 */
class ComponentsTest extends BearFrameworkAddonTestCase
{

    /**
     * 
     */
    public function testProccess()
    {
        $app = $this->getApp();

        $content = '<!DOCTYPE html><html><head></head><body>content</body></html>';
        $result = $app->components->process('<component src="data:base64,' . base64_encode($content) . '"></component>');
        $this->assertTrue($result === $content);
    }

    /**
     * 
     */
    public function testAlias()
    {
        $app = $this->getApp();

        $content = '<!DOCTYPE html><html><head></head><body>content</body></html>';
        $app->components->addAlias('newContent', 'data:base64,' . base64_encode($content));
        $result = $app->components->process('<component src="newContent" />');
        $this->assertTrue($result === $content);
    }

    /**
     * 
     */
    public function testFile()
    {
        $app = $this->getApp();

        $this->createFile($app->config->appDir . '/component1.php', '<!DOCTYPE html><html><head></head><body>content1<component src="file:' . $app->config->appDir . '/component2.php" /></body></html>');
        $this->createFile($app->config->appDir . '/component2.php', '<!DOCTYPE html><html><head></head><body>content2</body></html>');

        $app->components->addAlias('component1', 'file:' . $app->config->appDir . '/component1.php');

        $expectedResult = '<!DOCTYPE html><html><head></head><body>content1content2</body></html>';

        $result = $app->components->process('<component src="file:' . $app->config->appDir . '/component1.php" />');
        $this->assertTrue($result === $expectedResult);

        $result = $app->components->process('<component src="component1" />');
        $this->assertTrue($result === $expectedResult);

        $result = $app->components->processFile($app->config->appDir . '/component1.php');
        $this->assertTrue($result === $expectedResult);
    }

    /**
     * 
     */
    public function testInvalidArguments1()
    {
        $app = $this->getApp();
{'fraction_non_alphanumeric': 0.2095192537670414, 'fraction_numerical': 0.011002152595072949, 'mean_word_length': 3.091976516634051, 'pattern_counts': {'":': 0, '<': 88, '<?xml version=': 0, '>': 148, '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': '482850', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1229, 'n_words': 188}