Skip to content
Permalink
Browse files

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
  • Loading branch information...
Adirelle authored and tvbeek committed Mar 3, 2015
1 parent 9590336 commit 452a5ba97c7846b95f7933177d3d41db90f0cb9b
Showing with 492 additions and 272 deletions.
  1. +1 −1 PHPCI/Helper/Lang.php
  2. +1 −1 PHPCI/Plugin/Util/Factory.php
  3. +9 −8 Tests/PHPCI/Command/CreateAdminCommandTest.php
  4. +20 −9 Tests/PHPCI/Command/InstallCommandTest.php
  5. +5 −5 Tests/PHPCI/Controller/WebhookControllerTest.php
  6. +16 −1 Tests/PHPCI/Helper/AnsiConverterTest.php
  7. +11 −4 Tests/PHPCI/Helper/BuildInterpolatorTest.php
  8. +15 −4 Tests/PHPCI/Helper/CommandExecutorTest.php
  9. +10 −3 Tests/PHPCI/Helper/LangTest.php
  10. +4 −3 Tests/PHPCI/Helper/MailerFactoryTest.php
  11. +11 −4 Tests/PHPCI/Logging/BuildLoggerTest.php
  12. +10 −2 Tests/PHPCI/Logging/LoggerConfigTest.php
  13. +5 −3 Tests/PHPCI/Model/BuildTest.php
  14. +5 −3 Tests/PHPCI/Model/ProjectTest.php
  15. +18 −14 Tests/PHPCI/Plugin/EmailTest.php
  16. +11 −3 Tests/PHPCI/Plugin/PharTest.php
  17. +10 −2 Tests/PHPCI/Plugin/Util/ComposerPluginInformationTest.php
  18. +10 −1 Tests/PHPCI/Plugin/Util/ExamplePluginConfig.php
  19. +0 −78 Tests/PHPCI/Plugin/Util/ExamplePlugins.php
  20. +19 −9 Tests/PHPCI/Plugin/Util/ExecutorTest.php
  21. +42 −36 Tests/PHPCI/Plugin/Util/FactoryTest.php
  22. +36 −0 Tests/PHPCI/Plugin/Util/Fake/ExamplePluginFull.php
  23. +20 −0 Tests/PHPCI/Plugin/Util/Fake/ExamplePluginWithNoConstructorArgs.php
  24. +26 −0 Tests/PHPCI/Plugin/Util/Fake/ExamplePluginWithSingleOptionalArg.php
  25. +29 −0 Tests/PHPCI/Plugin/Util/Fake/ExamplePluginWithSingleRequiredArg.php
  26. +29 −0 Tests/PHPCI/Plugin/Util/Fake/ExamplePluginWithSingleTypedRequiredArg.php
  27. +10 −2 Tests/PHPCI/Plugin/Util/FilesPluginInformationTest.php
  28. +10 −1 Tests/PHPCI/Plugin/Util/TapParserTest.php
  29. +4 −3 Tests/PHPCI/Service/BuildServiceTest.php
  30. +5 −3 Tests/PHPCI/Service/ProjectServiceTest.php
  31. +4 −3 Tests/PHPCI/Service/UserServiceTest.php
  32. +1 −0 Tests/bootstrap.php
  33. +7 −3 composer.json
  34. +58 −63 composer.lock
  35. +8 −0 loggerconfig.php.example
  36. +8 −0 phinx.php
  37. +4 −0 phpci.yml
@@ -156,7 +156,7 @@ protected static function loadLanguage()
return null;
}
require_once($langFile);
require($langFile);
if (is_null($strings) || !is_array($strings) || !count($strings)) {
return null;
@@ -185,7 +185,7 @@ private function getParamType(\ReflectionParameter $param)
return $class->getName();
} elseif ($param->isArray()) {
return self::TYPE_ARRAY;
} elseif ($param->isCallable()) {
} elseif (is_callable($param)) {
return self::TYPE_CALLABLE;
} else {
return null;
@@ -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 @@ public function setup()
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 @@ public function testExecute()
$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());
}
@@ -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 @@ protected function getInstallCommandMock()
'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;
}
@@ -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()
{
@@ -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";
@@ -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 @@ public function testInterpolate_LeavesStringsUnchangedWhenBuildIsSet()
$this->assertEquals($expectedOutput, $actualOutput);
}
}
@@ -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 @@ public function testFindBinary_ReturnsPathInSpecifiedRoot()
$returnValue = $this->testedExecutor->findBinary($thisFileName);
$this->assertEquals(__DIR__ . "/" . $thisFileName, $returnValue);
}
}
}
@@ -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()
{
@@ -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;
@@ -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 @@ public function testLogFailure_AddsExceptionContext()
$this->testedBuildLogger->logFailure($message, $exception);
}
}
@@ -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 @@ public function testGetFor_IgnoresAlternativeHandlers()
$this->assertNotSame($alternativeHandler, $actualHandler);
}
}
@@ -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;
@@ -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;
Oops, something went wrong.

0 comments on commit 452a5ba

Please sign in to comment.
You can’t perform that action at this time.