1
0
Fork 0

SCA: reduced repetitive methods references, used specialized PhpUnit assertions

pull/7036/head
Vladimir Reznichenko 2018-01-24 10:19:46 +01:00
parent bcfb34b9c8
commit da9e00066c
7 changed files with 24 additions and 19 deletions

View File

@ -66,8 +66,9 @@ EOT
$composer = $this->getComposer(false); $composer = $this->getComposer(false);
if ($composer) { if ($composer) {
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent); $eventDispatcher = $composer->getEventDispatcher();
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD); $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
$eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
} }
if (null === $input->getOption('format')) { if (null === $input->getOption('format')) {

View File

@ -180,8 +180,9 @@ class BaseDependencyCommand extends BaseCommand
// Render table // Render table
$renderer = new Table($output); $renderer = new Table($output);
$renderer->setStyle('compact'); $renderer->setStyle('compact');
$renderer->getStyle()->setVerticalBorderChar(''); $rendererStyle = $renderer->getStyle();
$renderer->getStyle()->setCellRowContentFormat('%s '); $rendererStyle->setVerticalBorderChar('');
$rendererStyle->setCellRowContentFormat('%s ');
$renderer->setRows($table)->render(); $renderer->setRows($table)->render();
} }

View File

@ -142,8 +142,9 @@ EOT
// Render table // Render table
$renderer = new Table($output); $renderer = new Table($output);
$renderer->setStyle('compact'); $renderer->setStyle('compact');
$renderer->getStyle()->setVerticalBorderChar(''); $rendererStyle = $renderer->getStyle();
$renderer->getStyle()->setCellRowContentFormat('%s '); $rendererStyle->setVerticalBorderChar('');
$rendererStyle->setCellRowContentFormat('%s ');
$renderer->setRows($table)->render(); $renderer->setRows($table)->render();
} }
} }

View File

@ -74,8 +74,9 @@ EOT
$table = new Table($output); $table = new Table($output);
$table->setStyle('compact'); $table->setStyle('compact');
$table->getStyle()->setVerticalBorderChar(''); $tableStyle = $table->getStyle();
$table->getStyle()->setCellRowContentFormat('%s '); $tableStyle->setVerticalBorderChar('');
$tableStyle->setCellRowContentFormat('%s ');
$table->setHeaders(array('Name', 'Version', 'License')); $table->setHeaders(array('Name', 'Version', 'License'));
foreach ($packages as $package) { foreach ($packages as $package) {
$table->addRow(array( $table->addRow(array(

View File

@ -124,8 +124,9 @@ EOT
$renderer = new Table($output); $renderer = new Table($output);
$renderer->setStyle('compact'); $renderer->setStyle('compact');
$renderer->getStyle()->setVerticalBorderChar(''); $rendererStyle = $renderer->getStyle();
$renderer->getStyle()->setCellRowContentFormat('%s '); $rendererStyle->setVerticalBorderChar('');
$rendererStyle->setCellRowContentFormat('%s ');
$renderer->setRows($table)->render(); $renderer->setRows($table)->render();
return 0; return 0;

View File

@ -169,7 +169,7 @@ final class StreamContextFactory
$header = explode("\r\n", $header); $header = explode("\r\n", $header);
} }
uasort($header, function ($el) { uasort($header, function ($el) {
return preg_match('{^content-type}i', $el) ? 1 : -1; return stripos($el, 'content-type') === 0 ? 1 : -1;
}); });
return $header; return $header;

View File

@ -307,9 +307,9 @@ class FilesystemTest extends TestCase
$this->assertTrue($fs->isJunction($junction . '/../junction')); $this->assertTrue($fs->isJunction($junction . '/../junction'));
// Remove junction // Remove junction
$this->assertTrue(is_dir($junction)); $this->assertDirectoryExists($junction);
$this->assertTrue($fs->removeJunction($junction)); $this->assertTrue($fs->removeJunction($junction));
$this->assertFalse(is_dir($junction)); $this->assertDirectoryNotExists($junction);
} }
public function testCopy() public function testCopy()
@ -325,9 +325,9 @@ class FilesystemTest extends TestCase
$result1 = $fs->copy($this->workingDir . '/foo', $this->workingDir . '/foop'); $result1 = $fs->copy($this->workingDir . '/foo', $this->workingDir . '/foop');
$this->assertTrue($result1, 'Copying directory failed.'); $this->assertTrue($result1, 'Copying directory failed.');
$this->assertTrue(is_dir($this->workingDir . '/foop'), 'Not a directory: ' . $this->workingDir . '/foop'); $this->assertDirectoryExists($this->workingDir . '/foop', 'Not a directory: ' . $this->workingDir . '/foop');
$this->assertTrue(is_dir($this->workingDir . '/foop/bar'), 'Not a directory: ' . $this->workingDir . '/foop/bar'); $this->assertDirectoryExists($this->workingDir . '/foop/bar', 'Not a directory: ' . $this->workingDir . '/foop/bar');
$this->assertTrue(is_dir($this->workingDir . '/foop/baz'), 'Not a directory: ' . $this->workingDir . '/foop/baz'); $this->assertDirectoryExists($this->workingDir . '/foop/baz', 'Not a directory: ' . $this->workingDir . '/foop/baz');
$this->assertTrue(is_file($this->workingDir . '/foop/foo.file'), 'Not a file: ' . $this->workingDir . '/foop/foo.file'); $this->assertTrue(is_file($this->workingDir . '/foop/foo.file'), 'Not a file: ' . $this->workingDir . '/foop/foo.file');
$this->assertTrue(is_file($this->workingDir . '/foop/bar/foobar.file'), 'Not a file: ' . $this->workingDir . '/foop/bar/foobar.file'); $this->assertTrue(is_file($this->workingDir . '/foop/bar/foobar.file'), 'Not a file: ' . $this->workingDir . '/foop/bar/foobar.file');
$this->assertTrue(is_file($this->workingDir . '/foop/baz/foobaz.file'), 'Not a file: ' . $this->workingDir . '/foop/baz/foobaz.file'); $this->assertTrue(is_file($this->workingDir . '/foop/baz/foobaz.file'), 'Not a file: ' . $this->workingDir . '/foop/baz/foobaz.file');
@ -355,8 +355,8 @@ class FilesystemTest extends TestCase
$this->assertFalse(is_file($this->workingDir . '/foo/baz/foobaz.file'), 'Still a file: ' . $this->workingDir . '/foo/baz/foobaz.file'); $this->assertFalse(is_file($this->workingDir . '/foo/baz/foobaz.file'), 'Still a file: ' . $this->workingDir . '/foo/baz/foobaz.file');
$this->assertFalse(is_file($this->workingDir . '/foo/bar/foobar.file'), 'Still a file: ' . $this->workingDir . '/foo/bar/foobar.file'); $this->assertFalse(is_file($this->workingDir . '/foo/bar/foobar.file'), 'Still a file: ' . $this->workingDir . '/foo/bar/foobar.file');
$this->assertFalse(is_file($this->workingDir . '/foo/foo.file'), 'Still a file: ' . $this->workingDir . '/foo/foo.file'); $this->assertFalse(is_file($this->workingDir . '/foo/foo.file'), 'Still a file: ' . $this->workingDir . '/foo/foo.file');
$this->assertFalse(is_dir($this->workingDir . '/foo/baz'), 'Still a directory: ' . $this->workingDir . '/foo/baz'); $this->assertDirectoryNotExists($this->workingDir . '/foo/baz', 'Still a directory: ' . $this->workingDir . '/foo/baz');
$this->assertFalse(is_dir($this->workingDir . '/foo/bar'), 'Still a directory: ' . $this->workingDir . '/foo/bar'); $this->assertDirectoryNotExists($this->workingDir . '/foo/bar', 'Still a directory: ' . $this->workingDir . '/foo/bar');
$this->assertFalse(is_dir($this->workingDir . '/foo'), 'Still a directory: ' . $this->workingDir . '/foo'); $this->assertDirectoryNotExists($this->workingDir . '/foo', 'Still a directory: ' . $this->workingDir . '/foo');
} }
} }