<commit_before><?php
/**
 * Example of how to set up a unit test
 * Test the functionality of the Erdiko framework static methods
 */
require_once dirname(__DIR__).'/ErdikoTestCase.php';


class ErdikoTest extends ErdikoTestCase
{
	public function HelloWorldTest()
	{
		// @todo add assertions here...
	}
}<commit_msg>Some test cases for Erdiko.php file<commit_after><?php
/**
 * Example of how to set up a unit test
 * Test the functionality of the Erdiko framework static methods
 */
require_once dirname(__DIR__).'/ErdikoTestCase.php';
use erdiko\core\Logger;


class ErdikoTest extends ErdikoTestCase
{
	public function HelloWorldTest()
	{
		// @todo add assertions here...
	}
	
	public function testWriteToFileAndReadFromFileThenDelete()
	{
		$webRoot = dirname(dirname(__DIR__));
		$string="Sample string";
		Erdiko::writeToFile($string,"sample.txt");
		$result=Erdiko::readFromFile("sample.txt");
        $this->assertTrue($result == $string);
		
		$string="Sample string";
		Erdiko::writeToFile($string,"sample.txt",$webRoot);
		$result2=Erdiko::readFromFile("sample.txt",$webRoot);
        $this->assertTrue($result2 == $string);
		
		Erdiko::deleteFile("sample.txt");
		$this->assertTrue(file_exists($webRoot."www/var/sample.txt") == false);
		
		Erdiko::deleteFile("sample.txt",$webRoot."");
		$this->assertTrue(file_exists($webRoot."/sample.txt") == false);
	}
	
	/*
	* @depends testWriteToFileAndReadFromFileThenDelete
	*/
	public function testMoveFileAndDelete()
	{
		$webRoot = dirname(dirname(__DIR__));
		$string="Sample string";
		Erdiko::writeToFile($string,"sample.txt");
		Erdiko::moveFile("sample.txt",$webRoot."/www");
		$this->assertTrue(file_exists($webRoot."/www/sample.txt") == true);
		Erdiko::deleteFile("sample.txt",$webRoot."/www");
	}
	
	/*
	* @depends testWriteToFileAndReadFromFileThenDelete
	*/
	public function testRenameFileAndDelete()
	{
		$webRoot = dirname(dirname(__DIR__));
		$string="Sample string";
		Erdiko::writeToFile($string,"sample.txt",$webRoot."/www");
		Erdiko::renameFile("sample.txt","sample2.txt",$webRoot."/www");
		$this->assertTrue(file_exists($webRoot."/www/sample2.txt") == true);
		Erdiko::deleteFile("sample2.txt",$webRoot."/www");
	}
	
	/*
	* @depends testWriteToFileAndReadFromFileThenDelete
	*/
	public function testCopyFileRenameAndDelete()
	{
		$webRoot = dirname(dirname(__DIR__));
		$string="Sample string";
		Erdiko::writeToFile($string,"sample.txt");
		Erdiko::copyFile("sample.txt",$webRoot."/www");
		$this->assertTrue(file_exists($webRoot."/www/sample.txt") == true);
		
		$string="Sample string";
		Erdiko::writeToFile($string,"sample.txt");
		Erdiko::copyFile("sample.txt",$webRoot,"sample2.txt",$webRoot."/www");
		$this->assertTrue(file_exists($webRoot."/sample2.txt") == true);
		
		Erdiko::deleteFile("sample.txt");
		Erdiko::deleteFile("sample.txt",$webRoot."/www");
		Erdiko::deleteFile("sample.txt",$webRoot);
	}
	
	public function testLogFunctionsReadFromFile()
	{
		$webRoot = dirname(dirname(__DIR__));
		$sampleText="This is a sample log for Erdiko class test";
		Erdiko::log($sampleText);
		$return=Erdiko::readFromFile("erdiko.log",$webRoot."/www/var/logs");
		$this->assertTrue(strpos($return,$sampleText) != false );	
		
		Erdiko::clearLog(true);
		$return=Erdiko::readFromFile("erdiko.log",$webRoot."/www/var/logs");
		$this->assertTrue(empty($return)==true);
		
		Erdiko::clearLog(true);
		Erdiko::log($sampleText,Logger::INFO);
		$return=Erdiko::readFromFile("erdiko.log",$webRoot."/www/var/logs");
		$this->assertTrue(strpos($return,$sampleText) != false && strpos($return,"Info") != false);
		
		Erdiko::clearLog(true);
		Erdiko::log($sampleText,Logger::ERROR);
		$return=Erdiko::readFromFile("erdiko_error.log",$webRoot."/www/var/logs");
		$this->assertTrue(strpos($return,$sampleText) != false && strpos($return,"Error") != false);
		
		Erdiko::clearLog(true);
		Erdiko::log(new Exception($sampleText));
		$return=Erdiko::readFromFile("erdiko_error.log",$webRoot."/www/var/logs");
		$this->assertTrue(strpos($return,$sampleText) != false );	
		
	}
}
{'fraction_non_alphanumeric': 0.1872992340004942, 'fraction_numerical': 0.001729676303434643, 'mean_word_length': 5.943396226415095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 17, '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': '5420872', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1394, 'n_words': 185}