Enforce "en" lang in tests.

Some tests compare the result to english strings.

Do not test UnixCommandExecutor on Windows.

PharTest: explain why PHAR writing test are skipped.

InstallCommandTest: mock checkRequirements to allow the tests to run.

Run php_parallel_lint before all other tests.

Close #846
This commit is contained in:
Adirelle 2015-03-03 17:18:17 +01:00 committed by Tobias van Beek
parent 9590336c49
commit 452a5ba97c
37 changed files with 492 additions and 272 deletions

View file

@ -156,7 +156,7 @@ class Lang
return null;
}
require_once($langFile);
require($langFile);
if (is_null($strings) || !is_array($strings) || !count($strings)) {
return null;

View file

@ -185,7 +185,7 @@ class Factory
return $class->getName();
} elseif ($param->isArray()) {
return self::TYPE_ARRAY;
} elseif ($param->isCallable()) {
} elseif (is_callable($param)) {
return self::TYPE_CALLABLE;
} else {
return null;

View file

@ -1,13 +1,14 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Plugin\Tests\Command;
namespace Tests\PHPCI\Plugin\Command;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
@ -34,17 +35,17 @@ class CreateAdminCommandTest extends \PHPUnit_Framework_TestCase
parent::setup();
$this->command = $this->getMockBuilder('PHPCI\\Command\\CreateAdminCommand')
->setConstructorArgs([$this->getMock('PHPCI\\Store\\UserStore')])
->setMethods(['reloadConfig'])
->setConstructorArgs(array($this->getMock('PHPCI\\Store\\UserStore')))
->setMethods(array('reloadConfig'))
->getMock()
;
$this->dialog = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\DialogHelper')
->setMethods([
->setMethods(array(
'ask',
'askAndValidate',
'askHiddenResponse',
])
))
->getMock()
;
@ -71,7 +72,7 @@ class CreateAdminCommandTest extends \PHPUnit_Framework_TestCase
$this->dialog->expects($this->at(2))->method('askHiddenResponse')->will($this->returnValue('foobar123'));
$commandTester = $this->getCommandTester();
$commandTester->execute([]);
$commandTester->execute(array());
$this->assertEquals('User account created!' . PHP_EOL, $commandTester->getDisplay());
}

View file

@ -1,16 +1,23 @@
<?php
namespace PHPCI\Plugin\Tests\Command;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Command;
use Symfony\Component\Console\Application;
use Prophecy\PhpUnit\ProphecyTestCase;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Console\Helper\HelperSet;
class InstallCommandTest extends ProphecyTestCase
class InstallCommandTest extends \PHPUnit_Framework_TestCase
{
protected $config;
protected $admin;
public $config;
public $admin;
protected $application;
public function setup()
@ -55,22 +62,26 @@ class InstallCommandTest extends ProphecyTestCase
'setupDatabase',
'createAdminUser',
'writeConfigFile',
'checkRequirements',
))
->getMock();
$self = $this;
$command->expects($this->once())->method('verifyNotInstalled')->willReturn(true);
$command->expects($this->once())->method('verifyDatabaseDetails')->willReturn(true);
$command->expects($this->once())->method('setupDatabase')->willReturn(true);
$command->expects($this->once())->method('createAdminUser')->will(
$this->returnCallback(function ($adm) {// use (&$admin) {
$this->admin = $adm;
$this->returnCallback(function ($adm) use ($self) {
$self->admin = $adm;
})
);
$command->expects($this->once())->method('writeConfigFile')->will(
$this->returnCallback(function ($cfg) { //use (&$config) {
$this->config = $cfg;
$this->returnCallback(function ($cfg) use ($self) {
$self->config = $cfg;
})
);
$command->expects($this->once())->method('checkRequirements');
return $command;
}

View file

@ -1,18 +1,18 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Tests\Controller;
namespace Tests\PHPCI\Controller;
use PHPCI\Controller\WebhookController;
use Prophecy\PhpUnit\ProphecyTestCase;
class WebhookControllerTest extends ProphecyTestCase
class WebhookControllerTest extends \PHPUnit_Framework_TestCase
{
public function test_wrong_action_name_return_json_with_error()
{

View file

@ -1,12 +1,27 @@
<?php
namespace PHPCI\Helper\Tests;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Helper;
use PHPCI\Helper\AnsiConverter;
use PHPUnit_Framework_TestCase;
class AnsiConverterTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
$this->markTestSkipped('External library do not support PHP 5.3');
}
}
public function testConvert_convertToHtml()
{
$input = "\e[31mThis is red !\e[0m";

View file

@ -1,11 +1,18 @@
<?php
namespace PHPCI\Plugin\Tests\Helper;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Helper;
use PHPCI\Helper\BuildInterpolator;
use Prophecy\PhpUnit\ProphecyTestCase;
class BuildInterpolatorTest extends ProphecyTestCase
class BuildInterpolatorTest extends \PHPUnit_Framework_TestCase
{
/**
* @var BuildInterpolator
@ -46,4 +53,4 @@ class BuildInterpolatorTest extends ProphecyTestCase
$this->assertEquals($expectedOutput, $actualOutput);
}
}

View file

@ -1,11 +1,18 @@
<?php
namespace PHPCI\Plugin\Tests\Helper;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Helper;
use PHPCI\Helper\UnixCommandExecutor;
use \Prophecy\PhpUnit\ProphecyTestCase;
class CommandExecutorTest extends ProphecyTestCase
class CommandExecutorTest extends \PHPUnit_Framework_TestCase
{
/**
* @var UnixCommandExecutor
@ -14,6 +21,10 @@ class CommandExecutorTest extends ProphecyTestCase
protected function setUp()
{
if (IS_WIN) {
$this->markTestSkipped("Cannot test UnixCommandExecutor on ".PHP_OS);
return;
}
parent::setUp();
$mockBuildLogger = $this->prophesize('PHPCI\Logging\BuildLogger');
$this->testedExecutor = new UnixCommandExecutor($mockBuildLogger->reveal(), __DIR__ . "/");
@ -52,4 +63,4 @@ class CommandExecutorTest extends ProphecyTestCase
$returnValue = $this->testedExecutor->findBinary($thisFileName);
$this->assertEquals(__DIR__ . "/" . $thisFileName, $returnValue);
}
}
}

View file

@ -1,12 +1,19 @@
<?php
namespace PHPCI\Tests\Helper;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Helper;
use DateTime;
use PHPCI\Helper\Lang;
use Prophecy\PhpUnit\ProphecyTestCase;
class LangTest extends ProphecyTestCase
class LangTest extends \PHPUnit_Framework_TestCase
{
public function testLang_UsePassedParameters()
{

View file

@ -1,13 +1,14 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Service\Tests;
namespace tests\PHPCI\Service;
use PHPCI\Helper\MailerFactory;

View file

@ -1,13 +1,20 @@
<?php
namespace PHPCI\Plugin\Tests\Helper;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Helper;
use PHPCI\Logging\BuildLogger;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTestCase;
use Psr\Log\LogLevel;
class BuildLoggerTest extends ProphecyTestCase
class BuildLoggerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var BuildLogger
@ -104,4 +111,4 @@ class BuildLoggerTest extends ProphecyTestCase
$this->testedBuildLogger->logFailure($message, $exception);
}
}

View file

@ -1,6 +1,14 @@
<?php
namespace PHPCI\Plugin\Tests\Helper;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Helper;
use \PHPCI\Logging\LoggerConfig;
@ -74,4 +82,4 @@ class LoggerConfigTest extends \PHPUnit_Framework_TestCase
$this->assertNotSame($alternativeHandler, $actualHandler);
}
}

View file

@ -1,13 +1,15 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Model\Tests;
namespace Tests\PHPCI\Model;
use PHPCI\Model\Build;
use PHPCI\Model;

View file

@ -1,13 +1,15 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Model\Tests;
namespace Tests\PHPCI\Model;
use PHPCI\Model\Project;
use PHPCI\Model;

View file

@ -1,13 +1,14 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2013, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Plugin\Tests;
namespace Tests\PHPCI\Plugin;
use PHPCI\Plugin\Email as EmailPlugin;
use PHPCI\Model\Build;
@ -42,22 +43,23 @@ class EmailTest extends \PHPUnit_Framework_TestCase
/**
* @var int buildStatus
*/
protected $buildStatus;
public $buildStatus;
/**
* @var array $message;
*/
protected $message;
public $message;
/**
* @var bool $mailDelivered
*/
protected $mailDelivered;
public $mailDelivered;
public function setUp()
{
$this->message = array();
$this->mailDelivered = true;
$self = $this;
$this->mockProject = $this->getMock(
'\PHPCI\Model\Project',
@ -85,8 +87,8 @@ class EmailTest extends \PHPUnit_Framework_TestCase
$this->mockBuild->expects($this->any())
->method('getStatus')
->will($this->returnCallback(function () {
return $this->buildStatus;
->will($this->returnCallback(function () use ($self) {
return $self->buildStatus;
}));
$this->mockBuild->expects($this->any())
@ -138,6 +140,8 @@ class EmailTest extends \PHPUnit_Framework_TestCase
// Reset current message.
$this->message = array();
$self = $this;
$this->testedEmailPlugin = $this->getMock(
'\PHPCI\Plugin\Email',
array('sendEmail'),
@ -150,13 +154,13 @@ class EmailTest extends \PHPUnit_Framework_TestCase
$this->testedEmailPlugin->expects($this->any())
->method('sendEmail')
->will($this->returnCallback(function ($to, $cc, $subject, $body) {
$this->message['to'][] = $to;
$this->message['cc'] = $cc;
$this->message['subject'] = $subject;
$this->message['body'] = $body;
->will($this->returnCallback(function ($to, $cc, $subject, $body) use ($self) {
$self->message['to'][] = $to;
$self->message['cc'] = $cc;
$self->message['subject'] = $subject;
$self->message['body'] = $body;
return $this->mailDelivered;
return $self->mailDelivered;
}));
}

View file

@ -1,5 +1,14 @@
<?php
namespace PHPCI\Plugin\Tests;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin;
use PHPCI\Plugin\Phar as PharPlugin;
use Phar as PHPPhar;
@ -78,8 +87,7 @@ class PharTest extends \PHPUnit_Framework_TestCase
protected function checkReadonly()
{
if (ini_get('phar.readonly')) {
$this->markTestSkipped();
throw new RuntimeException('Readonly Phar');
$this->markTestSkipped('phar writing disabled in php.ini.');
}
}

View file

@ -1,6 +1,14 @@
<?php
namespace PHPCI\Plugin\Tests\Util;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util;
use PHPCI\Plugin\Util\ComposerPluginInformation;
@ -48,4 +56,4 @@ class ComposerPluginInformationTest extends \PHPUnit_Framework_TestCase
$this->assertContainsOnly("string", $classes);
}
}

View file

@ -1,4 +1,13 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
return function (PHPCI\Plugin\Util\Factory $factory) {
$factory->registerResource(
// This function will be called when the resource is needed.
@ -10,4 +19,4 @@ return function (PHPCI\Plugin\Util\Factory $factory) {
"requiredArgument",
null
);
};
};

View file

@ -1,78 +0,0 @@
<?php
namespace PHPCI\Plugin\Tests\Util;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Plugin;
class ExamplePluginWithNoConstructorArgs implements Plugin
{
public function execute()
{
}
}
class ExamplePluginWithSingleOptionalArg implements Plugin
{
function __construct($optional = null)
{
}
public function execute()
{
}
}
class ExamplePluginWithSingleRequiredArg implements Plugin
{
public $RequiredArgument;
function __construct($requiredArgument)
{
$this->RequiredArgument = $requiredArgument;
}
public function execute()
{
}
}
class ExamplePluginWithSingleTypedRequiredArg implements Plugin
{
public $RequiredArgument;
function __construct(\stdClass $requiredArgument)
{
$this->RequiredArgument = $requiredArgument;
}
public function execute()
{
}
}
class ExamplePluginFull implements Plugin {
public $Options;
public function __construct(
Builder $phpci,
Build $build,
array $options = array()
)
{
$this->Options = $options;
}
public function execute()
{
}
}

View file

@ -1,14 +1,19 @@
<?php
namespace PHPCI\Plugin\Tests\Util;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
require_once __DIR__ . "/ExamplePlugins.php";
namespace Tests\PHPCI\Plugin\Util;
use PHPCI\Plugin\Util\Executor;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTestCase;
class ExecutorTest extends ProphecyTestCase
class ExecutorTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Executor
@ -43,14 +48,13 @@ class ExecutorTest extends ProphecyTestCase
public function testExecutePlugin_KeepsCalledNameSpace()
{
$options = array();
$pluginName = 'ExamplePluginFull';
$pluginNamespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$pluginClass = $this->getFakePluginClassName('ExamplePluginFull');
$this->mockFactory->buildPlugin($pluginNamespace . $pluginName, $options)
$this->mockFactory->buildPlugin($pluginClass, $options)
->shouldBeCalledTimes(1)
->willReturn($this->prophesize('PHPCI\Plugin')->reveal());
$this->testedExecutor->executePlugin($pluginNamespace . $pluginName, $options);
$this->testedExecutor->executePlugin($pluginClass, $options);
}
public function testExecutePlugin_CallsExecuteOnFactoryBuildPlugin()
@ -142,5 +146,11 @@ class ExecutorTest extends ProphecyTestCase
$this->testedExecutor->executePlugins($config, 'stageOne');
}
protected function getFakePluginClassName($pluginName)
{
$pluginNamespace = '\\Tests\\PHPCI\\Plugin\\Util\\Fake\\';
return $pluginNamespace . $pluginName;
}
}

View file

@ -1,8 +1,14 @@
<?php
namespace PHPCI\Plugin\Tests\Util;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
require_once __DIR__ . "/ExamplePlugins.php";
namespace Tests\PHPCI\Plugin\Util;
use PHPCI\Plugin\Util\Factory;
@ -49,10 +55,9 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
public function testBuildPluginWorksWithConstructorlessPlugins()
{
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$expectedPluginClass = $namespace .'ExamplePluginWithNoConstructorArgs';
$plugin = $this->testedFactory->buildPlugin($expectedPluginClass);
$this->assertInstanceOf($expectedPluginClass, $plugin);
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithNoConstructorArgs');
$plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertInstanceOf($pluginClass, $plugin);
}
public function testBuildPluginFailsForNonPluginClasses()
@ -63,10 +68,9 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
public function testBuildPluginWorksWithSingleOptionalArgConstructor()
{
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$expectedPluginClass = $namespace . 'ExamplePluginWithSingleOptionalArg';
$plugin = $this->testedFactory->buildPlugin($expectedPluginClass);
$this->assertInstanceOf($expectedPluginClass, $plugin);
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleOptionalArg');
$plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertInstanceOf($pluginClass, $plugin);
}
public function testBuildPluginThrowsExceptionIfMissingResourcesForRequiredArg()
@ -76,15 +80,13 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
'Unsatisfied dependency: requiredArgument'
);
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$expectedPluginClass = $namespace . 'ExamplePluginWithSingleRequiredArg';
$plugin = $this->testedFactory->buildPlugin($expectedPluginClass);
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleRequiredArg');
$plugin = $this->testedFactory->buildPlugin($pluginClass);
}
public function testBuildPluginLoadsArgumentsBasedOnName()
{
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$expectedPluginClass = $namespace . 'ExamplePluginWithSingleRequiredArg';
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleRequiredArg');
$this->testedFactory->registerResource(
$this->resourceLoader,
@ -92,15 +94,14 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
);
/** @var ExamplePluginWithSingleRequiredArg $plugin */
$plugin = $this->testedFactory->buildPlugin($expectedPluginClass);
$plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertEquals($this->expectedResource, $plugin->RequiredArgument);
}
public function testBuildPluginLoadsArgumentsBasedOnType()
{
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$expectedPluginClass = $namespace . 'ExamplePluginWithSingleTypedRequiredArg';
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleTypedRequiredArg');
$this->testedFactory->registerResource(
$this->resourceLoader,
@ -109,28 +110,26 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
);
/** @var ExamplePluginWithSingleTypedRequiredArg $plugin */
$plugin = $this->testedFactory->buildPlugin($expectedPluginClass);
$plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertEquals($this->expectedResource, $plugin->RequiredArgument);
}
public function testBuildPluginLoadsFullExample()
{
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$expectedPluginClass = $namespace . 'ExamplePluginFull';
$pluginClass = $this->getFakePluginClassName('ExamplePluginFull');
$this->registerBuildAndBuilder();
/** @var ExamplePluginFull $plugin */
$plugin = $this->testedFactory->buildPlugin($expectedPluginClass);
$plugin = $this->testedFactory->buildPlugin($pluginClass);
$this->assertInstanceOf($expectedPluginClass, $plugin);
$this->assertInstanceOf($pluginClass, $plugin);
}
public function testBuildPluginLoadsFullExampleWithOptions()
{
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$expectedPluginClass = $namespace . 'ExamplePluginFull';
$pluginClass = $this->getFakePluginClassName('ExamplePluginFull');
$expectedArgs = array(
'thing' => "stuff"
@ -140,7 +139,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
/** @var ExamplePluginFull $plugin */
$plugin = $this->testedFactory->buildPlugin(
$expectedPluginClass,
$pluginClass,
$expectedArgs
);
@ -163,10 +162,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
realpath(__DIR__ . "/ExamplePluginConfig.php")
);
$namespace = '\\PHPCI\\Plugin\\Tests\\Util\\';
$pluginName = $namespace . 'ExamplePluginWithSingleRequiredArg';
$plugin = $this->testedFactory->buildPlugin($pluginName);
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleRequiredArg');
$plugin = $this->testedFactory->buildPlugin($pluginClass);
// The Example config file defines an array as the resource.
$this->assertEquals(
@ -181,9 +178,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
*/
private function registerBuildAndBuilder()
{
$self = $this;
$this->testedFactory->registerResource(
function () {
return $this->getMock(
function () use ($self) {
return $self->getMock(
'PHPCI\Builder',
array(),
array(),
@ -196,8 +195,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
);
$this->testedFactory->registerResource(
function () {
return $this->getMock(
function () use ($self) {
return $self->getMock(
'PHPCI\Model\Build',
array(),
array(),
@ -206,8 +205,15 @@ class FactoryTest extends \PHPUnit_Framework_TestCase {
);
},
null,
'PHPCI\\Model\Build'
'PHPCI\\Model\\Build'
);
}
protected function getFakePluginClassName($pluginName)
{
$pluginNamespace = '\\Tests\\PHPCI\\Plugin\\Util\\Fake\\';
return $pluginNamespace . $pluginName;
}
}

View file

@ -0,0 +1,36 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Plugin;
class ExamplePluginFull implements Plugin {
/**
* @var array
*/
public $Options;
public function __construct(
Builder $phpci,
Build $build,
array $options = array()
)
{
$this->Options = $options;
}
public function execute()
{
}
}

View file

@ -0,0 +1,20 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithNoConstructorArgs implements Plugin
{
public function execute()
{
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithSingleOptionalArg implements Plugin
{
function __construct($optional = null)
{
}
public function execute()
{
}
}

View file

@ -0,0 +1,29 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithSingleRequiredArg implements Plugin
{
public $RequiredArgument;
function __construct($requiredArgument)
{
$this->RequiredArgument = $requiredArgument;
}
public function execute()
{
}
}

View file

@ -0,0 +1,29 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithSingleTypedRequiredArg implements Plugin
{
public $RequiredArgument;
function __construct(\stdClass $requiredArgument)
{
$this->RequiredArgument = $requiredArgument;
}
public function execute()
{
}
}

View file

@ -1,6 +1,14 @@
<?php
namespace PHPCI\Plugin\Tests\Util;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util;
use PHPCI\Plugin\Util\FilesPluginInformation;
@ -23,4 +31,4 @@ class FilesPluginInformationTest extends \PHPUnit_Framework_TestCase
$this->assertContainsOnly('string', $pluginInfos);
}
}

View file

@ -1,5 +1,14 @@
<?php
namespace PHPCI\Plugin\Tests\Util;
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2015, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace Tests\PHPCI\Plugin\Util;
use PHPCI\Plugin\Util\TapParser;

View file

@ -1,13 +1,14 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Service\Tests;
namespace Tests\PHPCI\Service;
use PHPCI\Model\Build;
use PHPCI\Model\Project;

View file

@ -1,13 +1,15 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Service\Tests;
namespace Tests\PHPCI\Service;
use PHPCI\Model\Project;
use PHPCI\Service\ProjectService;

View file

@ -1,13 +1,14 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Service\Tests;
namespace Tests\PHPCI\Service;
use PHPCI\Model\User;
use PHPCI\Service\UserService;

View file

@ -40,3 +40,4 @@ if (file_exists($configFile)) {
require_once(dirname(__DIR__) . '/vars.php');
\PHPCI\Helper\Lang::init($config);
\PHPCI\Helper\Lang::setLanguage("en");

View file

@ -41,12 +41,16 @@
"monolog/monolog": "~1.6",
"pimple/pimple": "~1.1",
"robmorgan/phinx": "~0.4",
"sensiolabs/ansi-to-html": "~1.1"
"sensiolabs/ansi-to-html": "~1.1",
"jakub-onderka/php-parallel-lint": "0.8.*"
},
"autoload-dev": {
"psr-4": { "Tests\\PHPCI\\": "Tests/PHPCI" }
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/prophecy-phpunit": "~1.0",
"phpunit/phpunit": "~4.5",
"phpmd/phpmd": "~2.0",
"squizlabs/php_codesniffer": "~2.0",
"block8/php-docblock-checker": "~1.0",

121
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "5fc23800ea77b50b496d34f7aa5cf6b3",
"hash": "0c9efd3a0b9e924c7465e03fc97ffed7",
"packages": [
{
"name": "block8/b8framework",
@ -95,6 +95,53 @@
],
"time": "2014-11-20 16:49:30"
},
{
"name": "jakub-onderka/php-parallel-lint",
"version": "v0.8",
"source": {
"type": "git",
"url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git",
"reference": "2b242dcdbdd7369d2a746518ac31bb30c514b728"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/2b242dcdbdd7369d2a746518ac31bb30c514b728",
"reference": "2b242dcdbdd7369d2a746518ac31bb30c514b728",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"jakub-onderka/php-console-highlighter": "~0.3",
"nette/tester": "~1.3"
},
"suggest": {
"jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet"
},
"bin": [
"parallel-lint"
],
"type": "library",
"autoload": {
"classmap": [
"./"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "jakub.onderka@gmail.com"
}
],
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
"homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint",
"time": "2014-10-05 10:19:39"
},
{
"name": "monolog/monolog",
"version": "1.12.0",
@ -172,12 +219,12 @@
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Pimple.git",
"url": "https://github.com/silexphp/Pimple.git",
"reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fabpot/Pimple/zipball/2019c145fe393923f3441b23f29bbdfaa5c58c4d",
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/2019c145fe393923f3441b23f29bbdfaa5c58c4d",
"reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d",
"shasum": ""
},
@ -202,9 +249,7 @@
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
"email": "fabien@symfony.com"
}
],
"description": "Pimple is a simple Dependency Injection Container for PHP 5.3",
@ -977,56 +1022,6 @@
],
"time": "2014-11-17 16:23:49"
},
{
"name": "phpspec/prophecy-phpunit",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy-phpunit.git",
"reference": "0d06c84b9f26aab2b9940354f0fe6037dd9799c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy-phpunit/zipball/0d06c84b9f26aab2b9940354f0fe6037dd9799c3",
"reference": "0d06c84b9f26aab2b9940354f0fe6037dd9799c3",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpspec/prophecy": "~1.3"
},
"suggest": {
"phpunit/phpunit": "if it is not installed globally"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Prophecy\\PhpUnit\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"description": "PhpUnit test case integrating the Prophecy mocking library",
"homepage": "http://phpspec.net",
"keywords": [
"phpunit",
"prophecy"
],
"time": "2015-02-09 11:20:26"
},
{
"name": "phpunit/php-code-coverage",
"version": "2.0.15",
@ -1273,16 +1268,16 @@
},
{
"name": "phpunit/phpunit",
"version": "4.5.0",
"version": "4.5.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "5b578d3865a9128b9c209b011fda6539ec06e7a5"
"reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5b578d3865a9128b9c209b011fda6539ec06e7a5",
"reference": "5b578d3865a9128b9c209b011fda6539ec06e7a5",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d6429b0995b24a2d9dfe5587ee3a7071c1161af4",
"reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4",
"shasum": ""
},
"require": {
@ -1292,8 +1287,8 @@
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpspec/prophecy": "~1.3.1",
"phpunit/php-code-coverage": "~2.0",
"phpspec/prophecy": "~1.3,>=1.3.1",
"phpunit/php-code-coverage": "~2.0,>=2.0.11",
"phpunit/php-file-iterator": "~1.3.2",
"phpunit/php-text-template": "~1.2",
"phpunit/php-timer": "~1.0.2",
@ -1341,7 +1336,7 @@
"testing",
"xunit"
],
"time": "2015-02-05 15:51:19"
"time": "2015-03-29 09:24:05"
},
{
"name": "phpunit/phpunit-mock-objects",

View file

@ -1,5 +1,13 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
return array(
/** Loggers attached to every command */
"_" => function() {

View file

@ -1,5 +1,13 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
require_once(dirname(__FILE__) . '/bootstrap.php');
$writeServers = $config->get('b8.database.servers.write');

View file

@ -15,6 +15,10 @@ setup:
prefer_dist: false
test:
php_parallel_lint:
ignore:
# Only ignore vendor
- vendor/
php_mess_detector:
allowed_warnings: 0
php_code_sniffer: