Files
abcParser/tests/unit/AbcParser/Domain/Modules/Interpreter/ContextTest.php
2018-04-24 21:11:23 -04:00

71 lines
1.7 KiB
PHP

<?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);
}
}