for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: matthias
* Date: 01.12.15
* Time: 22:10
*/
namespace ComposerRequireCheckerTest\Cli;
use ComposerRequireChecker\Cli\Options;
use PHPUnit\Framework\TestCase;
class OptionsTest extends TestCase
{
public function testOptionsAcceptPhpCoreExtensions()
$options = new Options([
'php-core-extensions' => ['something']
]);
$this->assertSame(['something'], $options->getPhpCoreExtensions());
}
public function testOptionsAcceptSymbolWhitelist()
'symbol-whitelist' => ['foo', 'bar']
$this->assertSame(['foo', 'bar'], $options->getSymbolWhitelist());
public function testOptionsFileRepresentsDefaults()
$options = new Options();
$optionsFromFile = new Options(
json_decode(file_get_contents(
__DIR__ . '/../../../data/config.dist.json'
), true)
);
$this->assertEquals($options, $optionsFromFile);
public function testThrowsExceptionForUnknownOptions()
$this->expectException('InvalidArgumentException');
$options
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
'foo-bar' => ['foo', 'bar']
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.