New PHPUnit plugin fixes for PHP Censor

This commit is contained in:
Dmitry Khomutov 2017-01-05 20:01:53 +07:00
commit f3e8acc4bd
8 changed files with 45 additions and 61 deletions

View file

@ -8,9 +8,9 @@
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin;
namespace Tests\PHPCensor\Plugin;
use PHPCI\Plugin\Option\PhpUnitOptions;
use PHPCensor\Plugin\Option\PhpUnitOptions;
/**
* Unit test for the PHPUnitOptions parser
@ -124,8 +124,8 @@ class PhpUnitOptionsTest extends \PHPUnit_Framework_TestCase
$this->assertEmpty($options->getDirectories());
$this->assertEmpty($options->getConfigFiles());
$files = $options->getConfigFiles(PHPCI_DIR);
$files = $options->getConfigFiles(ROOT_DIR);
$this->assertFileExists(PHPCI_DIR . $files[0]);
$this->assertFileExists(ROOT_DIR . $files[0]);
}
}

View file

@ -8,7 +8,7 @@
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin;
namespace Tests\PHPCensor\Plugin;
/**
* Unit test for the PHPUnit plugin.
@ -20,11 +20,11 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
public function testSingleConfigFile()
{
$options = array(
'config' => PHPCI_DIR . 'phpunit.xml'
'config' => ROOT_DIR . 'phpunit.xml'
);
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('runConfigFile'))->getMock();
$mockPlugin->expects($this->once())->method('runConfigFile')->with(PHPCI_DIR . 'phpunit.xml');
$mockPlugin->expects($this->once())->method('runConfigFile')->with(ROOT_DIR . 'phpunit.xml');
$mockPlugin->execute();
}
@ -33,14 +33,14 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
{
$options = array(
'config' => array(
PHPCI_DIR . 'phpunit1.xml',
PHPCI_DIR . 'phpunit2.xml',
ROOT_DIR . 'phpunit1.xml',
ROOT_DIR . 'phpunit2.xml',
)
);
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('runConfigFile'))->getMock();
$mockPlugin->expects($this->exactly(2))->method('runConfigFile')->withConsecutive(
array(PHPCI_DIR . 'phpunit1.xml'), array(PHPCI_DIR . 'phpunit2.xml')
array(ROOT_DIR . 'phpunit1.xml'), array(ROOT_DIR . 'phpunit2.xml')
);
$mockPlugin->execute();
@ -60,12 +60,12 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
->setMethods(array('addRecord'))
->getMock();
$mockBuild = $this->getMockBuilder('\PHPCI\Model\Build')->getMock();
$mockBuilder = $this->getMockBuilder('\PHPCI\Builder')
$mockBuild = $this->getMockBuilder('\PHPCensor\Model\Build')->getMock();
$mockBuilder = $this->getMockBuilder('\PHPCensor\Builder')
->setConstructorArgs(array($mockBuild, $loggerMock))
->setMethods(array('executeCommand'))->getMock();
return $this->getMockBuilder('PHPCI\Plugin\PhpUnitV2')->setConstructorArgs(
return $this->getMockBuilder('PHPCensor\Plugin\PhpUnit')->setConstructorArgs(
array($mockBuilder, $mockBuild, $options)
);
}
@ -102,7 +102,7 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
public function testProcessResultsFromConfig()
{
$options = array(
'config' => PHPCI_DIR . 'phpunit.xml'
'config' => ROOT_DIR . 'phpunit.xml'
);
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('processResults'))->getMock();
@ -114,7 +114,7 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
public function testProcessResultsFromDir()
{
$options = array(
'directory' => PHPCI_DIR . 'Tests'
'directory' => ROOT_DIR . 'Tests'
);
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('processResults'))->getMock();

View file

@ -1,4 +1,5 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
@ -7,9 +8,9 @@
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util;
namespace Tests\PHPCensor\Plugin\Util;
use PHPCI\Plugin\Util\PhpUnitResult;
use PHPCensor\Plugin\Util\PhpUnitResult;
/**
* Class PhpUnitResultTest parses the results for the PhpUnitV2 plugin
@ -23,7 +24,7 @@ class PhpUnitResultTest extends \PHPUnit_Framework_TestCase
public function testInitParse()
{
$buildPath = '/path/to/build';
$parser = new PhpUnitResult(PHPCI_DIR . 'Tests/PHPCI/Plugin/SampleFiles/phpunit_money.txt', $buildPath);
$parser = new PhpUnitResult(ROOT_DIR . 'tests/PHPCensor/Plugin/SampleFiles/phpunit_money.txt', $buildPath);
$output = $parser->parse()->getResults();
$errors = $parser->getErrors();
@ -49,7 +50,7 @@ class PhpUnitResultTest extends \PHPUnit_Framework_TestCase
$this->setExpectedException('\Exception', 'Failed to parse the JSON output');
$buildPath = '/path/to/build';
$parser = new PhpUnitResult(PHPCI_DIR . 'Tests/PHPCI/Plugin/SampleFiles/invalid_format.txt', $buildPath);
$parser = new PhpUnitResult(ROOT_DIR . 'tests/PHPCensor/Plugin/SampleFiles/invalid_format.txt', $buildPath);
$parser->parse();
}
}