Files
abcParser/tests/unit/AbcParser/Domain/Modules/Interpreter/ContextTest.php
richard 1130f9a22f
Some checks failed
abc-api/abcParser/pipeline/head There was a failure building this commit
update to lumen 7
2020-06-24 11:58:32 -04:00

72 lines
1.7 KiB
PHP
Executable File

<?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 PHPUnit_Framework_TestCase;
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->assertIsString($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);
}
}