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 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<?php
declare( strict_types = 1 );
namespace MediaWiki\Tests\Unit\composer\PhpUnitSplitter;
use MediaWiki\Composer\PhpUnitSplitter\PhpUnitXml;
use PHPUnit\Framework\TestCase;
/**
* @license GPL-2.0-or-later
* @covers \MediaWiki\Composer\PhpUnitSplitter\PhpUnitXml
*/
class PhpUnitXmlTest extends TestCase {
private const BASIC_XML = '<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/phpunit/bootstrap.php">
<testsuites>
<testsuite name="core:unit">
<directory>tests/phpunit/unit</directory>
</testsuite>
</testsuites>
</phpunit>';
public function createFixtureFile( string $data ): string {
$filename = tempnam( sys_get_temp_dir(), "phpunit-test" );
file_put_contents( $filename, $data );
return $filename;
}
public function testFixtureContainsNoSplitGroups() {
$phpUnitXmlFile = $this->createFixtureFile( self::BASIC_XML );
$phpUnitXml = new PhpUnitXml( $phpUnitXmlFile );
$this->assertFalse( $phpUnitXml->containsSplitGroups(), "No split groups expected in fixture" );
unlink( $phpUnitXmlFile );
}
public function testAddSplitGroups() {
$phpUnitXmlFile = $this->createFixtureFile( self::BASIC_XML );
$phpUnitXml = new PhpUnitXml( $phpUnitXmlFile );
$phpUnitXml->addSplitGroups( [
[ "file1.php", "file2.php" ],
[ "file3.php", "file4.php" ],
[ "file7.php", "file6.php" ],
[ "file9.php", "file8.php" ],
[ "file11.php", "file10.php" ],
[ "file13.php", "file12.php" ],
] );
$this->assertTrue( $phpUnitXml->containsSplitGroups(), "Expected groups to be added" );
unlink( $phpUnitXmlFile );
}
}
|