Skip to content

Commit 236e2d9

Browse files
committed
Split tests per directory, exclude them unless explicitly triggered
1 parent cc2ee57 commit 236e2d9

2 files changed

Lines changed: 60 additions & 6 deletions

File tree

phpunit.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55
<directory suffix="Test.php">tests/Mf2</directory>
66
</testsuite>
77
</testsuites>
8+
<groups>
9+
<exclude>
10+
<group>microformats/tests/mf1</group>
11+
<group>microformats/tests/mf2</group>
12+
<group>microformats/tests/mixed</group>
13+
</exclude>
14+
</groups>
815
</phpunit>

tests/Mf2/MicroformatsTestSuiteTest.php

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,36 @@
55
class MicroformatsTestSuiteTest extends \PHPUnit_Framework_TestCase
66
{
77
/**
8-
* @dataProvider htmlAndJsonProvider
8+
* @dataProvider mf1TestsProvider
9+
* @group microformats/tests/mf1
910
*/
10-
public function testFromTestSuite($input, $expectedOutput)
11+
public function testMf1FromTestSuite($input, $expectedOutput)
12+
{
13+
$parser = new \Mf2\Parser($input, 'http://example.com/');
14+
$this->assertEquals(
15+
$this->makeComparible(json_decode($expectedOutput, true)),
16+
$this->makeComparible(json_decode(json_encode($parser->parse()), true))
17+
);
18+
}
19+
20+
/**
21+
* @dataProvider mf2TestsProvider
22+
* @group microformats/tests/mf2
23+
*/
24+
public function testMf2FromTestSuite($input, $expectedOutput)
25+
{
26+
$parser = new \Mf2\Parser($input, 'http://example.com/');
27+
$this->assertEquals(
28+
$this->makeComparible(json_decode($expectedOutput, true)),
29+
$this->makeComparible(json_decode(json_encode($parser->parse()), true))
30+
);
31+
}
32+
33+
/**
34+
* @dataProvider mixedTestsProvider
35+
* @group microformats/tests/mixed
36+
*/
37+
public function testMixedFromTestSuite($input, $expectedOutput)
1138
{
1239
$parser = new \Mf2\Parser($input, 'http://example.com/');
1340
$this->assertEquals(
@@ -36,14 +63,16 @@ public function makeComparible($array)
3663
}
3764

3865
/**
39-
* Data provider lists all tests from mf2/tests.
66+
* Data provider lists all tests from a specific directory in mf2/tests.
4067
**/
41-
public function htmlAndJsonProvider()
68+
public function htmlAndJsonProvider($subFolder = '')
4269
{
70+
// Get the actual wanted subfolder.
71+
$subFolder = '/mf2/tests/tests' . $subFolder;
4372
// Ripped out of the test-suite.php code:
4473
$finder = new \RegexIterator(
4574
new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(
46-
dirname(__FILE__) . '/../../vendor/mf2/tests/tests',
75+
dirname(__FILE__) . '/../../vendor/' . $subFolder,
4776
\RecursiveDirectoryIterator::SKIP_DOTS
4877
)),
4978
'/^.+\.html$/i',
@@ -53,7 +82,7 @@ public function htmlAndJsonProvider()
5382
$tests = array();
5483
foreach ($finder as $key => $value) {
5584
$dir = realpath(pathinfo($key, PATHINFO_DIRNAME));
56-
$testname = substr($dir, strpos($dir, '/mf2/tests/tests/') + 17) . '/' . pathinfo($key, PATHINFO_FILENAME);
85+
$testname = substr($dir, strpos($dir, $subFolder) + strlen($subFolder) + 1) . '/' . pathinfo($key, PATHINFO_FILENAME);
5786
$test = pathinfo($key, PATHINFO_BASENAME);
5887
$result = pathinfo($key, PATHINFO_FILENAME) . '.json';
5988
if (is_file($dir . '/' . $result)) {
@@ -65,4 +94,22 @@ public function htmlAndJsonProvider()
6594
}
6695
return $tests;
6796
}
97+
98+
/**
99+
* Following three functions are the actual dataProviders used by the test methods.
100+
*/
101+
public function mf1TestsProvider()
102+
{
103+
return $this->htmlAndJsonProvider('/microformats-v1');
104+
}
105+
106+
public function mf2TestsProvider()
107+
{
108+
return $this->htmlAndJsonProvider('/microformats-v2');
109+
}
110+
111+
public function mixedTestsProvider()
112+
{
113+
return $this->htmlAndJsonProvider('/microformats-mixed');
114+
}
68115
}

0 commit comments

Comments
 (0)