-
Notifications
You must be signed in to change notification settings - Fork 1
/
ArchieMLTest.php
38 lines (35 loc) · 1.18 KB
/
ArchieMLTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
class ArchieMLTest extends \PHPUnit_Framework_TestCase
{
const TEST_FILES = 'test/archieml.org/test/1.0/*.aml';
public function testBasic()
{
$this->assertSame('value', ArchieML::load('key:value
this is ignored')['key'], 'parses key value pairs');
}
/**
* @dataProvider sharedProvider
*/
public function testShared($expected, $actual, $message)
{
$this->assertEquals($expected, $actual, $message);
}
public function sharedProvider()
{
// $this->markTestSkipped();
$tests = [];
foreach (glob(self::TEST_FILES) as $filename) {
# TODO: whats up with: metadata = load(..., { comments: false})
$category = basename($filename, '.aml');
if ($category == 'all.0')
continue;
$actual = ArchieML::load(file_get_contents($filename));
$message = $actual['test'];
$expected = json_decode($actual['result'], true);
unset($actual['test'], $actual['result']);
$tests[$category] = [ $expected, $actual, $message ];
}
return $tests;
}
}