Initial import from aternosorg/codex-minecraft
This commit is contained in:
35
test/tests/Printer/DefaultPrinterTest.php
Normal file
35
test/tests/Printer/DefaultPrinterTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Tests\Printer;
|
||||
|
||||
use Aternos\Codex\Log\Entry;
|
||||
use Aternos\Codex\Log\File\PathLogFile;
|
||||
use Aternos\Codex\Log\Line;
|
||||
use Aternos\Codex\Log\Log;
|
||||
use Aternos\Codex\Printer\DefaultPrinter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DefaultPrinterTest extends TestCase
|
||||
{
|
||||
public function testPrint(): void
|
||||
{
|
||||
$logFile = new PathLogFile(__DIR__ . "/../../data/simple.log");
|
||||
$log = new Log();
|
||||
$log->setLogFile($logFile);
|
||||
$log->parse();
|
||||
|
||||
$printer = new DefaultPrinter();
|
||||
$printer->setLog($log);
|
||||
$this->assertEquals($logFile->getContent(), trim($printer->print()));
|
||||
}
|
||||
|
||||
public function testPrintEntry(): void
|
||||
{
|
||||
$text = uniqid();
|
||||
$entry = (new Entry())->addLine(new Line(1, $text));
|
||||
|
||||
$printer = new DefaultPrinter();
|
||||
$printer->setEntry($entry);
|
||||
$this->assertEquals($text, trim($printer->print()));
|
||||
}
|
||||
}
|
||||
38
test/tests/Printer/ModifiableDefaultPrinterTest.php
Normal file
38
test/tests/Printer/ModifiableDefaultPrinterTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Tests\Printer;
|
||||
|
||||
use Aternos\Codex\Log\Entry;
|
||||
use Aternos\Codex\Log\File\StringLogFile;
|
||||
use Aternos\Codex\Log\Line;
|
||||
use Aternos\Codex\Log\Log;
|
||||
use Aternos\Codex\Printer\ModifiableDefaultPrinter;
|
||||
use Aternos\Codex\Test\Src\Printer\TestModification;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ModifiableDefaultPrinterTest extends TestCase
|
||||
{
|
||||
|
||||
public function testPrint(): void
|
||||
{
|
||||
$logFile = new StringLogFile("This is foo!");
|
||||
$log = new Log();
|
||||
$log->setLogFile($logFile);
|
||||
$log->parse();
|
||||
|
||||
$printer = new ModifiableDefaultPrinter();
|
||||
$printer->addModification(new TestModification());
|
||||
$printer->setLog($log);
|
||||
$this->assertEquals("This is bar!", trim($printer->print()));
|
||||
}
|
||||
|
||||
public function testPrintEntry(): void
|
||||
{
|
||||
$entry = (new Entry())->addLine(new Line(1, "This is foo!"));
|
||||
|
||||
$printer = new ModifiableDefaultPrinter();
|
||||
$printer->setModifications([new TestModification()]);
|
||||
$printer->setEntry($entry);
|
||||
$this->assertEquals("This is bar!", trim($printer->print()));
|
||||
}
|
||||
}
|
||||
25
test/tests/Printer/PatternModificationTest.php
Normal file
25
test/tests/Printer/PatternModificationTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Tests\Printer;
|
||||
|
||||
use Aternos\Codex\Log\File\StringLogFile;
|
||||
use Aternos\Codex\Log\Log;
|
||||
use Aternos\Codex\Printer\ModifiableDefaultPrinter;
|
||||
use Aternos\Codex\Printer\PatternModification;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PatternModificationTest extends TestCase
|
||||
{
|
||||
public function testPrint(): void
|
||||
{
|
||||
$logFile = new StringLogFile("This is foo!");
|
||||
$log = new Log();
|
||||
$log->setLogFile($logFile);
|
||||
$log->parse();
|
||||
|
||||
$printer = new ModifiableDefaultPrinter();
|
||||
$printer->addModification(new PatternModification('/foo/', 'bar'));
|
||||
$printer->setLog($log);
|
||||
$this->assertEquals("This is bar!", trim($printer->print()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user