Code style fixes

This commit is contained in:
Dmitry Khomutov 2017-01-08 00:55:56 +07:00
parent 041f8090b0
commit 4b49c95b20
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
8 changed files with 121 additions and 121 deletions

View file

@ -14,15 +14,15 @@ class AddUserProviders extends AbstractMigration
$this
->table('user')
// The provider name
->addColumn('provider_key', 'string', array(
->addColumn('provider_key', 'string', [
'default' => 'internal',
'limit' => MysqlAdapter::TEXT_SMALL
))
'limit' => MysqlAdapter::TEXT_SMALL
])
// A data used by the provider
->addColumn('provider_data', 'string', array(
'null' => true,
->addColumn('provider_data', 'string', [
'null' => true,
'limit' => MysqlAdapter::TEXT_SMALL
))
])
->save();
}

View file

@ -20,7 +20,7 @@ namespace PHPCensor\Plugin\Option;
class PhpUnitOptions
{
protected $options;
protected $arguments = array();
protected $arguments = [];
public function __construct($options)
{
@ -52,7 +52,7 @@ class PhpUnitOptions
$prefix = $argumentName[0] == '-' ? '' : '--';
if (!is_array($argumentValues)) {
$argumentValues = array($argumentValues);
$argumentValues = [$argumentValues];
}
foreach ($argumentValues as $argValue) {
@ -139,7 +139,7 @@ class PhpUnitOptions
if (isset($this->arguments[$argumentName])) {
if (!is_array($this->arguments[$argumentName])) {
// Convert existing argument values into an array
$this->arguments[$argumentName] = array($this->arguments[$argumentName]);
$this->arguments[$argumentName] = [$this->arguments[$argumentName]];
}
// Appends the new argument to the list
@ -160,14 +160,14 @@ class PhpUnitOptions
$directories = $this->getOption('directory');
if (is_string($directories)) {
$directories = array($directories);
$directories = [$directories];
} else {
if (is_null($directories)) {
$directories = array();
$directories = [];
}
}
return is_array($directories) ? $directories : array($directories);
return is_array($directories) ? $directories : [$directories];
}
/**
@ -240,10 +240,10 @@ class PhpUnitOptions
if (isset($this->arguments[$argumentName])) {
return is_array(
$this->arguments[$argumentName]
) ? $this->arguments[$argumentName] : array($this->arguments[$argumentName]);
) ? $this->arguments[$argumentName] : [$this->arguments[$argumentName]];
}
return array();
return [];
}
/**
@ -255,12 +255,12 @@ class PhpUnitOptions
*/
public static function findConfigFile($buildPath)
{
$files = array(
$files = [
'phpunit.xml',
'phpunit.xml.dist',
'tests/phpunit.xml',
'tests/phpunit.xml.dist',
);
];
foreach ($files as $file) {
if (file_exists($buildPath . $file)) {

View file

@ -30,7 +30,7 @@ use PHPCensor\ZeroConfigPluginInterface;
class PhpUnit extends Plugin implements ZeroConfigPluginInterface
{
/** @var string[] Raw options from the PHPCI config file */
protected $options = array();
protected $options = [];
/**
* @return string

View file

@ -29,10 +29,10 @@ class PhpUnitResult
const SEVERITY_SKIPPED = 'skipped';
protected $options;
protected $arguments = array();
protected $arguments = [];
protected $results;
protected $failures = 0;
protected $errors = array();
protected $errors = [];
public function __construct($outputFile, $buildPath = '')
{
@ -60,8 +60,8 @@ class PhpUnitResult
}
// Reset the parsing variables
$this->results = array();
$this->errors = array();
$this->results = [];
$this->errors = [];
$this->failures = 0;
if (is_array($events)) {
@ -88,13 +88,13 @@ class PhpUnitResult
{
list($pass, $severity) = $this->getStatus($event);
$data = array(
$data = [
'pass' => $pass,
'severity' => $severity,
'message' => $this->buildMessage($event),
'trace' => $pass ? array() : $this->buildTrace($event),
'trace' => $pass ? [] : $this->buildTrace($event),
'output' => $event['output'],
);
];
if (!$pass) {
$this->failures++;
@ -142,7 +142,7 @@ class PhpUnitResult
break;
}
return array($pass, $severity);
return [$pass, $severity];
}
/**
@ -172,7 +172,7 @@ class PhpUnitResult
*/
protected function buildTrace($event)
{
$formattedTrace = array();
$formattedTrace = [];
if (!empty($event['trace'])) {
foreach ($event['trace'] as $step){
@ -195,12 +195,12 @@ class PhpUnitResult
$firstTrace = end($event['trace']);
reset($event['trace']);
$this->errors[] = array(
$this->errors[] = [
'message' => $data['message'],
'severity' => $data['severity'],
'file' => str_replace($this->buildPath, '', $firstTrace['file']),
'line' => $firstTrace['line'],
);
];
}
/**

View file

@ -75,7 +75,7 @@ class CommandExecutorTest extends \PHPUnit_Framework_TestCase
/bin/sh -c 'data="$(printf %%${length}s | tr " " "-")"; >&2 echo "\$data"; >&1 echo "\$data"'
EOD;
$data = str_repeat("-", $length);
$returnValue = $this->testedExecutor->executeCommand(array($script));
$returnValue = $this->testedExecutor->executeCommand([$script]);
$this->assertTrue($returnValue);
$this->assertEquals($data, trim($this->testedExecutor->getLastOutput()));
$this->assertEquals($data, trim($this->testedExecutor->getLastError()));

View file

@ -21,80 +21,80 @@ class PhpUnitOptionsTest extends \PHPUnit_Framework_TestCase
{
public function validOptionsProvider()
{
return array(
array(
array(
return [
[
[
'config' => 'tests/phpunit.xml',
'args' => '--stop-on-error --log-junit /path/to/log/',
),
array(
],
[
'stop-on-error' => '',
'log-junit' => '/path/to/log/',
'configuration' => 'tests/phpunit.xml',
),
),
array(
array(
],
],
[
[
'coverage' => '/path/to/coverage2/',
'args' => array(
'args' => [
'coverage-html' => '/path/to/coverage1/',
),
),
array(
'coverage-html' => array(
],
],
[
'coverage-html' => [
'/path/to/coverage1/',
'/path/to/coverage2/',
),
),
),
array(
array(
'directory' => array(
],
],
],
[
[
'directory' => [
'/path/to/test1/',
'/path/to/test2/',
),
'args' => array(
],
'args' => [
'coverage-html' => '/path/to/coverage1/',
),
),
array(
],
],
[
'coverage-html' => '/path/to/coverage1/',
),
),
array(
array(
'config' => array('tests/phpunit.xml'),
],
],
[
[
'config' => ['tests/phpunit.xml'],
'args' => "--testsuite=unit --bootstrap=vendor/autoload.php",
),
array(
],
[
'testsuite' => 'unit',
'bootstrap' => 'vendor/autoload.php',
'configuration' => array('tests/phpunit.xml'),
),
),
array(
array(
'config' => array('tests/phpunit.xml'),
'configuration' => ['tests/phpunit.xml'],
],
],
[
[
'config' => ['tests/phpunit.xml'],
'args' => "--testsuite='unit' --bootstrap 'vendor/autoload.php'",
),
array(
],
[
'testsuite' => 'unit',
'bootstrap' => 'vendor/autoload.php',
'configuration' => array('tests/phpunit.xml'),
),
),
array(
array(
'config' => array('tests/phpunit.xml'),
'configuration' => ['tests/phpunit.xml'],
],
],
[
[
'config' => ['tests/phpunit.xml'],
'args' => '--testsuite="unit" --bootstrap "vendor/autoload.php"',
),
array(
],
[
'testsuite' => 'unit',
'bootstrap' => 'vendor/autoload.php',
'configuration' => array('tests/phpunit.xml'),
),
),
);
'configuration' => ['tests/phpunit.xml'],
],
],
];
}
/**
@ -112,10 +112,10 @@ class PhpUnitOptionsTest extends \PHPUnit_Framework_TestCase
public function testGetters()
{
$options = new PhpUnitOptions(
array(
[
'run_from' => '/path/to/run/from',
'path' => 'subTest',
)
]
);
$this->assertEquals('/path/to/run/from', $options->getRunFrom());

View file

@ -19,11 +19,11 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
{
public function testSingleConfigFile()
{
$options = array(
$options = [
'config' => ROOT_DIR . 'phpunit.xml'
);
];
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('runConfigFile'))->getMock();
$mockPlugin = $this->getPluginBuilder($options)->setMethods(['runConfigFile'])->getMock();
$mockPlugin->expects($this->once())->method('runConfigFile')->with(ROOT_DIR . 'phpunit.xml');
$mockPlugin->execute();
@ -31,16 +31,16 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
public function testMultiConfigFile()
{
$options = array(
'config' => array(
$options = [
'config' => [
ROOT_DIR . 'phpunit1.xml',
ROOT_DIR . 'phpunit2.xml',
)
);
]
];
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('runConfigFile'))->getMock();
$mockPlugin = $this->getPluginBuilder($options)->setMethods(['runConfigFile'])->getMock();
$mockPlugin->expects($this->exactly(2))->method('runConfigFile')->withConsecutive(
array(ROOT_DIR . 'phpunit1.xml'), array(ROOT_DIR . 'phpunit2.xml')
[ROOT_DIR . 'phpunit1.xml'], [ROOT_DIR . 'phpunit2.xml']
);
$mockPlugin->execute();
@ -53,30 +53,30 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
*
* @return \PHPUnit_Framework_MockObject_MockBuilder
*/
protected function getPluginBuilder($options = array())
protected function getPluginBuilder($options = [])
{
$loggerMock = $this->getMockBuilder('\Monolog\Logger')
->setConstructorArgs(array('Test'))
->setMethods(array('addRecord'))
->setConstructorArgs(['Test'])
->setMethods(['addRecord'])
->getMock();
$mockBuild = $this->getMockBuilder('\PHPCensor\Model\Build')->getMock();
$mockBuilder = $this->getMockBuilder('\PHPCensor\Builder')
->setConstructorArgs(array($mockBuild, $loggerMock))
->setMethods(array('executeCommand'))->getMock();
->setConstructorArgs([$mockBuild, $loggerMock])
->setMethods(['executeCommand'])->getMock();
return $this->getMockBuilder('PHPCensor\Plugin\PhpUnit')->setConstructorArgs(
array($mockBuilder, $mockBuild, $options)
[$mockBuilder, $mockBuild, $options]
);
}
public function testSingleDir()
{
$options = array(
$options = [
'directory' => '/test/directory/one'
);
];
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('runDir'))->getMock();
$mockPlugin = $this->getPluginBuilder($options)->setMethods(['runDir'])->getMock();
$mockPlugin->expects($this->once())->method('runDir')->with('/test/directory/one');
$mockPlugin->execute();
@ -84,16 +84,16 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
public function testMultiDir()
{
$options = array(
'directory' => array(
$options = [
'directory' => [
'/test/directory/one',
'/test/directory/two',
)
);
]
];
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('runDir'))->getMock();
$mockPlugin = $this->getPluginBuilder($options)->setMethods(['runDir'])->getMock();
$mockPlugin->expects($this->exactly(2))->method('runDir')->withConsecutive(
array('/test/directory/one'), array('/test/directory/two')
['/test/directory/one'], ['/test/directory/two']
);
$mockPlugin->execute();
@ -101,11 +101,11 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
public function testProcessResultsFromConfig()
{
$options = array(
$options = [
'config' => ROOT_DIR . 'phpunit.xml'
);
];
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('processResults'))->getMock();
$mockPlugin = $this->getPluginBuilder($options)->setMethods(['processResults'])->getMock();
$mockPlugin->expects($this->once())->method('processResults')->with($this->isType('string'));
$mockPlugin->execute();
@ -113,11 +113,11 @@ class PhpUnitTest extends \PHPUnit_Framework_TestCase
public function testProcessResultsFromDir()
{
$options = array(
$options = [
'directory' => ROOT_DIR . 'Tests'
);
];
$mockPlugin = $this->getPluginBuilder($options)->setMethods(array('processResults'))->getMock();
$mockPlugin = $this->getPluginBuilder($options)->setMethods(['processResults'])->getMock();
$mockPlugin->expects($this->once())->method('processResults')->with($this->isType('string'));
$mockPlugin->execute();

View file

@ -37,7 +37,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
*/
public function testBuildAnyProvider()
{
$config = array('type' => '\Tests\PHPCensor\Security\Authentication\DummyProvider');
$config = ['type' => '\Tests\PHPCensor\Security\Authentication\DummyProvider'];
$provider = Service::buildProvider("test", $config);
$this->assertInstanceOf('\Tests\PHPCensor\Security\Authentication\DummyProvider', $provider);
@ -50,9 +50,9 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
*/
public function testGetProviders()
{
$a = $this->prophesize('\PHPCensor\Security\Authentication\UserProvider')->reveal();
$b = $this->prophesize('\PHPCensor\Security\Authentication\UserProvider')->reveal();
$providers = array('a' => $a, 'b' => $b);
$a = $this->prophesize('\PHPCensor\Security\Authentication\UserProvider')->reveal();
$b = $this->prophesize('\PHPCensor\Security\Authentication\UserProvider')->reveal();
$providers = ['a' => $a, 'b' => $b];
$service = new Service($providers);
@ -64,13 +64,13 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
*/
public function testGetLoginPasswordProviders()
{
$a = $this->prophesize('\PHPCensor\Security\Authentication\UserProvider')->reveal();
$b = $this->prophesize('\PHPCensor\Security\Authentication\LoginPasswordProvider')->reveal();
$providers = array('a' => $a, 'b' => $b);
$a = $this->prophesize('\PHPCensor\Security\Authentication\UserProvider')->reveal();
$b = $this->prophesize('\PHPCensor\Security\Authentication\LoginPasswordProvider')->reveal();
$providers = ['a' => $a, 'b' => $b];
$service = new Service($providers);
$this->assertEquals(array('b' => $b), $service->getLoginPasswordProviders());
$this->assertEquals(['b' => $b], $service->getLoginPasswordProviders());
}
}