<commit_before><?php
/**
 * This file contains tests for Validator class
 *
 * @package Fajr
 * @subpackage Tests
 * @author <NAME> <<EMAIL>>
 */

/**
 * @ignore
 */
require_once 'test_include.php';

use \fajr\HtmlTrace;
/**
 * @ignore
 */
class HtmlTraceTest extends PHPUnit_Framework_TestCase
{
  private function newTimer() {
    return $this->getMock('\fajr\libfajr\base\Timer', array('getElapsedTime', 'reset'));
  }

  public function testRecursiveOutput()
  {
    $timer = $this->newTimer();
    $root = new HtmlTrace($timer, "root_h");
    $other = new HtmlTrace($timer, "other");
    $root->tlog("root_text");
    $c1 = $root->addChild("c1_h");
    $c2 = $root->addChild("c2_h");
    $cc = $c1->addChild("cc_h");
    $cc->tlog("cc_text");

    $root_html = $root->getHtml();
    $c1_html = $c1->getHtml();
    // all texts and headers should appear in the output
    $this->assertRegExp("@root_h@", $root_html);
    $this->assertRegExp("@root_text@", $root_html);
    $this->assertRegExp("@c1_h@", $root_html);
    $this->assertRegExp("@c2_h@", $root_html);
    $this->assertRegExp("@cc_h@", $root_html);
    $this->assertRegExp("@cc_text@", $root_html);

    $this->assertNotRegExp("@other@", $root_html);
    // root nodes shoudn't be shown in child
    $this->assertNotRegExp("@root_h@", $c1_html);
    $this->assertNotRegExp("@root_text@", $c1_html);
    $this->assertRegExp("@c1_h@", $c1_html);
  }

  public function testCallerData() {
    $data = HtmlTrace::getCallerData(0);
    $this->assertEquals(__CLASS__, $data['class']);
    $this->assertEquals(__FUNCTION__, $data['function']);
  }

  public function testVariableOutput() {<commit_msg>Fix trace testu po pridani CodeSnippetov<commit_after><?php
/**
 * This file contains tests for Validator class
 *
 * @package Fajr
 * @subpackage Tests
 * @author <NAME> <<EMAIL>>
 */

/**
 * @ignore
 */
require_once 'test_include.php';

use \fajr\HtmlTrace;
/**
 * @ignore
 */
class HtmlTraceTest extends PHPUnit_Framework_TestCase
{
  private function newTimer() {
    return $this->getMock('\fajr\libfajr\base\Timer', array('getElapsedTime', 'reset'));
  }

  public function testRecursiveOutput()
  {
    $timer = $this->newTimer();
    $root = new HtmlTrace($timer, "ROOT_H");
    $other = new HtmlTrace($timer, "OTHER");
    $root->tlog("ROOT_TEXT");
    $c1 = $root->addChild("C1_H");
    $c2 = $root->addChild("C2_H");
    $cc = $c1->addChild("CC_H");
    $cc->tlog("CC_TEXT");

    $root_html = $root->getHtml();
    $c1_html = $c1->getHtml();
    // all texts and headers should appear in the output
    $this->assertRegExp("@ROOT_H@", $root_html);
    $this->assertRegExp("@ROOT_TEXT@", $root_html);
    $this->assertRegExp("@C1_H@", $root_html);
    $this->assertRegExp("@C2_H@", $root_html);
    $this->assertRegExp("@CC_H@", $root_html);
    $this->assertRegExp("@CC_TEXT@", $root_html);

    //Asserthing NotRegExp is quite tricky as some lines of this file
    //are included in the trace itself (CodeSnippet feature)
    // We need to watch about @ $ &quot; ]
    $this->assertNotRegExp("@[^$;\@\]]OTHER@", $root_html);
    // root nodes shoudn't be shown in child
    $this->assertNotRegExp("@[^$;\@\]]ROOT_H@", $c1_html);
    $this->assertNotRegExp("@[^$;\@\]]ROOT_TEXT@", $c1_html);
    $this->assertRegExp("@C1_H@", $c1_html);
  }

  public function testCallerData() {
    $data = HtmlTrace::getCallerData(0);
    $this->assertEquals(__CLASS__, $data['class']);
    $this->assertEquals(__FUNCTION__, $data['function']);
  }

  public function testVariableOutput() {
{'fraction_non_alphanumeric': 0.19458544839255498, 'fraction_numerical': 0.007896221094190638, 'mean_word_length': 4.208516886930984, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, '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': '1600480', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1290, 'n_words': 240}