finished default parser

This commit is contained in:
2018-04-24 21:11:23 -04:00
parent 8a1c752045
commit 3817394951
39 changed files with 3725 additions and 328 deletions

View File

@@ -0,0 +1,70 @@
<?php
/**
* Created by PhpStorm.
* User: richard
* Date: 11/27/17
* Time: 6:14 AM
*/
namespace Tests\Unit\AbcParser\Domain\Modules\Interpreter;
use Enzyme\Axiom\Atoms\StringAtom;
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
class ContextTest extends \PHPUnit_Framework_TestCase
{
private function getAbc($filename = '/abc/valid_abc_1.abc')
{
return file_get_contents(codecept_data_dir($filename));
}
public function testCreate()
{
$abc = new StringAtom($this->getAbc());
$context = new Context($abc);
$this->assertInstanceOf(Context::class, $context);
}
public function testLoopingThroughLines()
{
$abc = new StringAtom($this->getAbc());
$context = new Context($abc);
$this->assertGreaterThan(1, count($context));
foreach ($context as $key => $line) {
$this->assertInternalType('string', $line);
}
}
public function testGetStateDefaultsToNoData()
{
$abc = new StringAtom($this->getAbc());
$context = new Context($abc);
$result = $context->getState();
$this->assertEquals(Context::MODE_NO_DATA, $result);
}
public function testSetStateInFileHeader()
{
$abc = new StringAtom($this->getAbc());
$context = new Context($abc);
$result = $context->setStateInFileHeader()->getState();
$this->assertEquals(Context::MODE_FILE_HEADER, $result);
}
public function testGetVersionReturnsDefault()
{
$expected = Context::ABC_VERSION_DEFAULT;
$abc = new StringAtom($this->getAbc());
$context = new Context($abc);
$result = $context->getVersion();
$this->assertEquals($expected, $result);
}
}