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
commit bc65445c05
37 changed files with 492 additions and 272 deletions

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");