diff --git a/composer.json b/composer.json
index 86228f0..7d7496f 100644
--- a/composer.json
+++ b/composer.json
@@ -10,10 +10,10 @@
"homepage": "https://dephpend.com",
"bin": ["bin/dephpend", "bin/php-trace"],
"require": {
- "php": "^7.2",
+ "php": "^8.2",
"nikic/php-parser": "^4.0",
- "symfony/console": "^4 || ^5",
- "symfony/event-dispatcher": "^4 || ^5"
+ "symfony/console": "^7",
+ "symfony/event-dispatcher": "^7"
},
"suggest": {
"ext-json": "*",
@@ -22,9 +22,9 @@
},
"require-dev": {
"mikey179/vfsstream": "^1.6",
- "phpunit/phpunit": "^8.0",
+ "phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.3",
- "friendsofphp/php-cs-fixer": "^2.12"
+ "friendsofphp/php-cs-fixer": "^v3.64.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
diff --git a/src/Cli/Application.php b/src/Cli/Application.php
index 29a66e4..54fb88e 100644
--- a/src/Cli/Application.php
+++ b/src/Cli/Application.php
@@ -45,7 +45,7 @@ public function setErrorOutput(ErrorOutput $errorOutput): void
*
* @throws \Symfony\Component\Console\Exception\LogicException
*/
- public function doRun(InputInterface $input, OutputInterface $output)
+ public function doRun(InputInterface $input, OutputInterface $output): int
{
$this->printWarningIfXdebugIsEnabled($input, $output);
diff --git a/src/Cli/DotCommand.php b/src/Cli/DotCommand.php
index d533cc4..40e06f7 100644
--- a/src/Cli/DotCommand.php
+++ b/src/Cli/DotCommand.php
@@ -45,7 +45,7 @@ protected function configure()
;
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$options = $input->getOptions();
$this->ensureDestinationIsWritable($options['output']);
diff --git a/src/Cli/DsmCommand.php b/src/Cli/DsmCommand.php
index 48c8d5f..fdde32e 100644
--- a/src/Cli/DsmCommand.php
+++ b/src/Cli/DsmCommand.php
@@ -24,7 +24,7 @@ public function __construct(DependencyStructureMatrixHtmlFormatter $dependencySt
$this->dependencyStructureMatrixHtmlFormatter = $dependencyStructureMatrixFormatter;
}
- protected function configure()
+ protected function configure(): void
{
parent::configure();
@@ -40,7 +40,7 @@ protected function configure()
;
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$options = $input->getOptions();
$this->ensureSourcesAreReadable($input->getArgument('source'));
diff --git a/src/Cli/MetricsCommand.php b/src/Cli/MetricsCommand.php
index fbdf38e..846da61 100644
--- a/src/Cli/MetricsCommand.php
+++ b/src/Cli/MetricsCommand.php
@@ -34,7 +34,7 @@ protected function configure()
*
* @throws \Symfony\Component\Console\Exception\InvalidArgumentException
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$table = new Table($output);
$table->setRows([
diff --git a/src/Cli/TestFeaturesCommand.php b/src/Cli/TestFeaturesCommand.php
index 6235ab3..03b6656 100644
--- a/src/Cli/TestFeaturesCommand.php
+++ b/src/Cli/TestFeaturesCommand.php
@@ -34,7 +34,7 @@ protected function configure()
/**
* @inheritDoc
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$files = $this->fetchAllFeatureTests();
$results = $this->runAllTests($files);
diff --git a/src/Cli/TextCommand.php b/src/Cli/TextCommand.php
index 4b3b254..d65383b 100644
--- a/src/Cli/TextCommand.php
+++ b/src/Cli/TextCommand.php
@@ -14,14 +14,14 @@ public function __construct()
parent::__construct('text');
}
- protected function configure()
+ protected function configure(): void
{
parent::configure();
$this->setDescription('Prints a list of all dependencies');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->ensureSourcesAreReadable($input->getArgument('source'));
diff --git a/src/Cli/UmlCommand.php b/src/Cli/UmlCommand.php
index a4a581f..da6a811 100644
--- a/src/Cli/UmlCommand.php
+++ b/src/Cli/UmlCommand.php
@@ -24,7 +24,7 @@ public function __construct(PlantUmlWrapper $plantUmlWrapper)
$this->allowedFormats = [$this->defaultFormat];
}
- protected function configure()
+ protected function configure(): void
{
parent::configure();
@@ -45,7 +45,7 @@ protected function configure()
;
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$options = $input->getOptions();
$this->ensureSourcesAreReadable($input->getArgument('source'));
diff --git a/tests/feature/DsmTest.php b/tests/feature/DsmTest.php
index 20fcb19..b307ccb 100644
--- a/tests/feature/DsmTest.php
+++ b/tests/feature/DsmTest.php
@@ -10,7 +10,7 @@ class DsmTest extends TestCase
{
public function testCreatesSimpleDsmInHtml(): void
{
- assertRegExp(
+ $this->assertRegExp(
'@\d: PhpParser
([1-9]\d*).+.+@s',
shell_exec(DEPHPEND_BIN.' dsm '.SRC_PATH.' --no-classes --depth=2 --format=html')
);
diff --git a/tests/feature/ListTest.php b/tests/feature/ListTest.php
index a441fcf..f09432d 100644
--- a/tests/feature/ListTest.php
+++ b/tests/feature/ListTest.php
@@ -10,6 +10,6 @@ class ListTest extends TestCase
{
public function testNoArgumentsShowsHelp(): void
{
- assertRegExp('/dsm.*metrics.*text.*uml.*/s', shell_exec(DEPHPEND_BIN.' list'));
+ $this->assertRegExp('/dsm.*metrics.*text.*uml.*/s', shell_exec(DEPHPEND_BIN.' list'));
}
}
diff --git a/tests/feature/MetricsTest.php b/tests/feature/MetricsTest.php
index c6e84f4..177c5c0 100644
--- a/tests/feature/MetricsTest.php
+++ b/tests/feature/MetricsTest.php
@@ -10,7 +10,7 @@ class MetricsTest extends TestCase
{
public function testComputeMetricsForDephpend(): void
{
- assertRegExp(
+ $this->assertRegExp(
'/Classes:.*\d\d.*Abstract classes:.*\d+.*Abstractness:.*\d\.\d+/s',
shell_exec(DEPHPEND_BIN.' metrics '.SRC_PATH)
);
diff --git a/tests/feature/TextTest.php b/tests/feature/TextTest.php
index cc8dbd8..31b0479 100644
--- a/tests/feature/TextTest.php
+++ b/tests/feature/TextTest.php
@@ -11,7 +11,7 @@ class TextTest extends TestCase
public function testTextCommandOnDephpendSourceWithoutClassesAndWithRegexAndFromFilter(): void
{
- assertEquals(
+ $this->assertEquals(
'Mihaeu\PhpDependencies\Analyser --> Mihaeu\PhpDependencies\Dependencies'.PHP_EOL
.'Mihaeu\PhpDependencies\Analyser --> Mihaeu\PhpDependencies\OS'.PHP_EOL,
shell_exec(DEPHPEND_BIN.' text '.SRC_PATH
diff --git a/tests/feature/UmlTest.php b/tests/feature/UmlTest.php
index 9a22316..d850b82 100644
--- a/tests/feature/UmlTest.php
+++ b/tests/feature/UmlTest.php
@@ -44,7 +44,7 @@ public function testCreatesUml(): void
$tempFileUml = sys_get_temp_dir().'/dephpend-uml-test.uml';
shell_exec(DEPHPEND_BIN.' uml '.SRC_PATH.' --no-classes --keep-uml '
.'--output="'.$tempFilePng.'" -f Mihaeu\\\\PhpDependencies\\\\OS');
- assertEquals(
+ $this->assertEquals(
$expected,
file_get_contents($tempFileUml)
);
diff --git a/tests/unit/Analyser/DefaultParserTest.php b/tests/unit/Analyser/DefaultParserTest.php
index ac885a5..e6275ed 100644
--- a/tests/unit/Analyser/DefaultParserTest.php
+++ b/tests/unit/Analyser/DefaultParserTest.php
@@ -15,6 +15,6 @@ public function testPassesCodeToBaseParser(): void
$baseParser = $this->createMock(Parser::class);
$baseParser->method('parse')->willReturn(['test']);
$parser = new DefaultParser($baseParser);
- assertEquals(['test'], $parser->parse(''));
+ $this->assertEquals(['test'], $parser->parse(''));
}
}
diff --git a/tests/unit/Analyser/DependencyInspectionVisitorTest.php b/tests/unit/Analyser/DependencyInspectionVisitorTest.php
index 99611ae..bc8b30b 100644
--- a/tests/unit/Analyser/DependencyInspectionVisitorTest.php
+++ b/tests/unit/Analyser/DependencyInspectionVisitorTest.php
@@ -122,7 +122,7 @@ public function testDetectsExplicitNewCreation(): void
$this->dependencyInspectionVisitor->enterNode($newNode);
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain($this->dependencyInspectionVisitor->dependencies(), new Clazz('TestDep')));
+ $this->assertTrue($this->dependenciesContain($this->dependencyInspectionVisitor->dependencies(), new Clazz('TestDep')));
}
public function testDetectsExtendedClasses(): void
@@ -136,7 +136,7 @@ public function testDetectsExtendedClasses(): void
$this->dependencyInspectionVisitor->enterNode($node);
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('ClassA', new Namespaze(['A', 'a', '1']))
));
@@ -157,11 +157,11 @@ public function testDetectsWhenInterfacesImplementMultipleInterfaces(): void
$this->dependencyInspectionVisitor->enterNode($node);
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('ClassA', new Namespaze(['A', 'a', '1']))
));
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('ClassB', new Namespaze(['B', 'b', '2']))
));
@@ -177,7 +177,7 @@ public function testDetectsAbstractClasses(): void
$this->addRandomDependency();
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new AbstractClazz('Test', new Namespaze(['A']))
));
@@ -193,7 +193,7 @@ public function testDetectsInterfaces(): void
$this->addRandomDependency();
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Interfaze('Test', new Namespaze(['A']))
));
@@ -213,11 +213,11 @@ public function testDetectsImplementedInterfaces(): void
$this->dependencyInspectionVisitor->enterNode($node);
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('InterfaceOne', new Namespaze(['A', 'B']))
));
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('InterfaceTwo', new Namespaze(['C', 'D']))
));
@@ -229,7 +229,7 @@ public function testIgnoresInnerClassesWithoutName(): void
$this->dependencyInspectionVisitor->enterNode($node);
$this->dependencyInspectionVisitor->leaveNode($node);
- assertEmpty($this->dependencyInspectionVisitor->dependencies());
+ $this->assertEmpty($this->dependencyInspectionVisitor->dependencies());
}
public function testDetectsDependenciesFromMethodArguments(): void
@@ -248,11 +248,11 @@ public function testDetectsDependenciesFromMethodArguments(): void
$this->addNodeToAst($methodNode);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('DependencyOne', new Namespaze(['A', 'B']))
));
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('DependencyTwo', new Namespaze(['A', 'B']))
));
@@ -266,7 +266,7 @@ public function testDetectsUseNodes(): void
)
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Test', new Namespaze(['A', 'a', '1']))
));
@@ -278,7 +278,7 @@ public function testReturnType(): void
new ClassMethod('', ['returnType' => new Name(['Namespace', 'Test'])])
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Test', new Namespaze(['Namespace']))
));
@@ -293,7 +293,7 @@ public function testDetectsCallsOnStaticClasses(): void
$this->dependencyInspectionVisitor->enterNode($staticCall);
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Singleton', new Namespaze(['A', 'a', '1']))
));
@@ -307,7 +307,7 @@ public function testAddsDependenciesOnlyWhenInClassContext(): void
// we leave the ClassNode, but we haven't entered it, so class context is unknown
$this->dependencyInspectionVisitor->leaveNode(new ClassNode('test'));
$dependencies = $this->dependencyInspectionVisitor->dependencies();
- assertEmpty($dependencies);
+ $this->assertEmpty($dependencies);
}
public function testTrait(): void
@@ -320,7 +320,7 @@ public function testTrait(): void
$this->addRandomDependency();
$this->dependencyInspectionVisitor->leaveNode($node);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test', new Namespaze(['A']))
));
@@ -332,7 +332,7 @@ public function testUseSingleTrait(): void
new TraitUse([new Name(['A', 'Test'])])
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test', new Namespaze(['A']))
));
@@ -348,15 +348,15 @@ public function testUseMultipleTraits(): void
])
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test', new Namespaze(['A']))
));
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test2', new Namespaze(['B']))
));
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test3', new Namespaze(['C']))
));
@@ -368,7 +368,7 @@ public function testUseInstanceofComparison(): void
new Instanceof_(new Array_(), new FullyQualifiedNameNode('Test'))
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Test')
));
@@ -380,7 +380,7 @@ public function testDetectsCatchNode(): void
new Catch_([new Name(['AnException'])], new Variable('e'))
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('AnException')
));
@@ -395,11 +395,11 @@ public function testDetectsPhp71MultipleCatchNodes(): void
], new Variable('e'))
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('AnException')
));
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('AnotherException')
));
@@ -411,7 +411,7 @@ public function testDetectsFetchClassNode(): void
new ClassConstFetch(new Name('StaticTest'), 'test')
);
- assertTrue($this->dependenciesContain(
+ $this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('StaticTest')
));
diff --git a/tests/unit/Analyser/MetricsTest.php b/tests/unit/Analyser/MetricsTest.php
index 63db362..a594ccb 100644
--- a/tests/unit/Analyser/MetricsTest.php
+++ b/tests/unit/Analyser/MetricsTest.php
@@ -39,27 +39,27 @@ protected function setUp(): void
public function testAbstractnessWithNoDependency(): void
{
- assertEquals(0, (new Metrics)->abstractness(new DependencyMap));
+ $this->assertEquals(0, (new Metrics)->abstractness(new DependencyMap));
}
public function testCountClasses(): void
{
- assertEquals(4, $this->metrics->classCount($this->dependencies));
+ $this->assertEquals(4, $this->metrics->classCount($this->dependencies));
}
public function testCountInterfaces(): void
{
- assertEquals(1, $this->metrics->interfaceCount($this->dependencies));
+ $this->assertEquals(1, $this->metrics->interfaceCount($this->dependencies));
}
public function testCountAbstractClasses(): void
{
- assertEquals(1, $this->metrics->abstractClassCount($this->dependencies));
+ $this->assertEquals(1, $this->metrics->abstractClassCount($this->dependencies));
}
public function testCountTraits(): void
{
- assertEquals(1, $this->metrics->traitCount($this->dependencies));
+ $this->assertEquals(1, $this->metrics->traitCount($this->dependencies));
}
public function testComputeAbstractness(): void
@@ -69,7 +69,7 @@ public function testComputeAbstractness(): void
public function testComputeAfferentCoupling(): void
{
- assertEquals([
+ $this->assertEquals([
'A' => 0,
'G' => 0,
'R' => 0,
@@ -83,7 +83,7 @@ public function testComputeAfferentCoupling(): void
public function testComputeEfferentCoupling(): void
{
// all my classes depend only on one dependency
- assertEquals([
+ $this->assertEquals([
'A' => 1,
'G' => 1,
'R' => 1,
@@ -96,7 +96,7 @@ public function testComputeEfferentCoupling(): void
public function testComputeInstability(): void
{
- assertEquals([
+ $this->assertEquals([
'A' => 1,
'G' => 1,
'R' => 1,
diff --git a/tests/unit/Analyser/StaticAnalyserTest.php b/tests/unit/Analyser/StaticAnalyserTest.php
index f3e0e53..cea64e5 100644
--- a/tests/unit/Analyser/StaticAnalyserTest.php
+++ b/tests/unit/Analyser/StaticAnalyserTest.php
@@ -47,7 +47,7 @@ public function testAnalyse(): void
$phpFile = $this->createMock(PhpFile::class);
$phpFile->method('code')->willReturn('');
$dependencies = $this->analyser->analyse((new PhpFileSet())->add($phpFile));
- assertEquals(new DependencyMap(), $dependencies);
+ $this->assertEquals(new DependencyMap(), $dependencies);
}
public function testEnrichesExceptionWhenParserThrows(): void
diff --git a/tests/unit/Analyser/XDebugFunctionTraceAnalyserTest.php b/tests/unit/Analyser/XDebugFunctionTraceAnalyserTest.php
index 3e6246d..7040430 100644
--- a/tests/unit/Analyser/XDebugFunctionTraceAnalyserTest.php
+++ b/tests/unit/Analyser/XDebugFunctionTraceAnalyserTest.php
@@ -7,6 +7,7 @@
use Mihaeu\PhpDependencies\DependencyHelper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Finder\SplFileInfo;
+use ValueError;
/**
* @covers Mihaeu\PhpDependencies\Analyser\XDebugFunctionTraceAnalyser
@@ -37,7 +38,7 @@ public function testAnalyse(): void
[0, 1, 2, 3, 4, 'B->c', 6, 7, 8, 9, 10, 'class A'],
[0, 1, 2, 3, 4, 'D->c', 6, 7, 8, 9, 10, 'class A'],
]);
- assertEquals(
+ $this->assertEquals(
DependencyHelper::map('
B --> A
D --> A
@@ -58,7 +59,7 @@ public function testAnalyseIgnoresScalarValues(): void
[0, 1, 2, 3, 4, 'D->c', 6, 7, 8, 9, 10, 'int'],
[0, 1, 2, 3, 4, 'D->c', 6, 7, 8, 9, 10, 'resource'],
]);
- assertEquals(
+ $this->assertEquals(
DependencyHelper::map('
B --> A
'),
@@ -70,13 +71,13 @@ public function testThrowsExceptionIfFileCannotBeOpened(): void
{
$tmpFile = $this->createMock(SplFileInfo::class);
$tmpFile->expects($this->once())->method('getPathname')->willReturn('');
- $this->expectException(InvalidArgumentException::class);
+ $this->expectException(ValueError::class);
$this->xDebugFunctionTraceAnalyser->analyse($tmpFile);
}
private function createContent(array $data) : string
{
- return array_reduce($data, function (string $carry, array $lineParts) {
+ return array_reduce($data, static function (string $carry, array $lineParts) {
return $carry.implode("\t", $lineParts).PHP_EOL;
}, '');
}
diff --git a/tests/unit/Cli/ApplicationTest.php b/tests/unit/Cli/ApplicationTest.php
index ea25072..6c5b127 100644
--- a/tests/unit/Cli/ApplicationTest.php
+++ b/tests/unit/Cli/ApplicationTest.php
@@ -56,9 +56,9 @@ public function testWarningIfXDebugEnabled(): void
// not sure how to mock this, so we test only one case, there's always one error message regarding
// Symfony console setup, so if there's no xdebug loaded we still see one message
if (!extension_loaded('xdebug')) {
- $errorOutput->expects(once())->method('writeln');
+ $errorOutput->expects($this->once())->method('writeln');
} else {
- $errorOutput->expects(exactly(2))->method('writeln');
+ $errorOutput->expects($this->exactly(2))->method('writeln');
}
$this->application->doRun($this->input, $this->output);
}
@@ -76,11 +76,15 @@ public function testPrintsErrorMessageIfParserThrowsException(): void
$errorOutput = $this->createMock(ErrorOutput::class);
$this->application->setErrorOutput($errorOutput);
if (!extension_loaded('xdebug')) {
- $errorOutput->expects(once())->method('writeln')->with($expectedMessage);
+ $errorOutput->expects($this->once())->method('writeln')->with($expectedMessage);
} else {
- $errorOutput->expects(exactly(2))->method('writeln')->withConsecutive(
- [self::XDEBUG_WARNING],
- [$expectedMessage]
+ $errorOutput->expects($this->exactly(2))->method('writeln')->willReturnCallback(
+ function ($message) use ($expectedMessage) {
+ if ($message === self::XDEBUG_WARNING) {
+ return;
+ }
+ $this->assertEquals($expectedMessage, $message);
+ }
);
}
$this->application->doRun($this->input, $this->output);
@@ -95,7 +99,7 @@ public function testValidatesDsmInput(): void
$application->setErrorOutput($errorOutput);
$returnCode = $application->doRun($this->input, $this->output);
- assertEquals(0, $returnCode);
+ $this->assertEquals(0, $returnCode);
}
public function testValidatesUmlInput(): void
@@ -107,7 +111,7 @@ public function testValidatesUmlInput(): void
$application->setErrorOutput($errorOutput);
$returnCode = $application->doRun($this->input, $this->output);
- assertEquals(0, $returnCode);
+ $this->assertEquals(0, $returnCode);
}
public function testValidatesMetricInput(): void
@@ -119,7 +123,7 @@ public function testValidatesMetricInput(): void
$application->setErrorOutput($errorOutput);
$returnCode = $application->doRun($this->input, $this->output);
- assertEquals(0, $returnCode);
+ $this->assertEquals(0, $returnCode);
}
public function testValidatesDotInput(): void
@@ -131,7 +135,7 @@ public function testValidatesDotInput(): void
$application->setErrorOutput($errorOutput);
$returnCode = $application->doRun($this->input, $this->output);
- assertEquals(0, $returnCode);
+ $this->assertEquals(0, $returnCode);
}
public function testCommandWithHelpOptionProvidesHelpForDotCommand(): void
@@ -149,7 +153,7 @@ public function testNoCommandWithVersionOptionWritesVersion(): void
$input = new ArgvInput(['', '--version']);
$output = new BufferedOutput();
(new Application('Test', '4.2.0', $this->dispatcher))->doRun($input, $output);
- assertRegExp('/\d+\.\d+\.\d+/', $output->fetch());
+ $this->assertMatchesRegularExpression('/\d+\.\d+\.\d+/', $output->fetch());
}
public function testNoCommandWithHelpOptionWritesHelp(): void
diff --git a/tests/unit/Cli/DispatcherTest.php b/tests/unit/Cli/DispatcherTest.php
index 9e2c6fa..799ac12 100644
--- a/tests/unit/Cli/DispatcherTest.php
+++ b/tests/unit/Cli/DispatcherTest.php
@@ -53,14 +53,14 @@ protected function setUp(): void
public function testTriggersOnlyOnNamedConsoleEvents(): void
{
$consoleEvent = $this->createMock(ConsoleEvent::class);
- $consoleEvent->expects(never())->method('getInput');
+ $consoleEvent->expects($this->never())->method('getInput');
$this->dispatcher->dispatch($consoleEvent, 'other event');
}
public function testTriggersOnlyOnConsoleEvents(): void
{
$consoleEvent = $this->createMock(GenericEvent::class);
- assertEquals(
+ $this->assertEquals(
$consoleEvent,
$this->dispatcher->dispatch(clone $consoleEvent, ConsoleEvents::COMMAND)
);
@@ -80,9 +80,9 @@ public function testInjectsDependenciesIntoConsoleEvents(): void
$input->method('getOption')->with('dynamic')->willReturn($traceFile);
$consoleEvent->method('getInput')->willReturn($input);
- $this->xDebugFunctionTraceAnalyser->expects(once())->method('analyse')->with($traceFile);
- $command->expects(once())->method('setDependencies');
- $command->expects(once())->method('setPostProcessors');
+ $this->xDebugFunctionTraceAnalyser->expects($this->once())->method('analyse')->with($traceFile);
+ $command->expects($this->once())->method('setDependencies');
+ $command->expects($this->once())->method('setPostProcessors');
$this->dispatcher->dispatch(clone $consoleEvent, ConsoleEvents::COMMAND);
}
}
diff --git a/tests/unit/Cli/DotCommandTest.php b/tests/unit/Cli/DotCommandTest.php
index c6185f2..77148b8 100644
--- a/tests/unit/Cli/DotCommandTest.php
+++ b/tests/unit/Cli/DotCommandTest.php
@@ -44,7 +44,7 @@ public function testGenerateDot(): void
'filter-namespace' => null,
'depth' => 0
]);
- $this->dotWrapper->expects(once())->method('generate');
+ $this->dotWrapper->expects($this->once())->method('generate');
$this->dotCommand->run(
$this->input,
diff --git a/tests/unit/Cli/DsmCommandTest.php b/tests/unit/Cli/DsmCommandTest.php
index 9a1d195..c54ecce 100644
--- a/tests/unit/Cli/DsmCommandTest.php
+++ b/tests/unit/Cli/DsmCommandTest.php
@@ -57,7 +57,7 @@ public function testPassesDependenciesToFormatter(): void
$dependencies = DependencyHelper::map('A --> B');
$this->dsmCommand->setDependencies($dependencies);
- $this->dependencyStructureMatrixFormatter->expects(once())->method('format')->with($dependencies);
+ $this->dependencyStructureMatrixFormatter->expects($this->once())->method('format')->with($dependencies);
$this->dsmCommand->run($this->input, $this->output);
}
diff --git a/tests/unit/Cli/ErrorOutputTest.php b/tests/unit/Cli/ErrorOutputTest.php
index b42755b..9ba59fd 100644
--- a/tests/unit/Cli/ErrorOutputTest.php
+++ b/tests/unit/Cli/ErrorOutputTest.php
@@ -31,7 +31,7 @@ public function setUp(): void
public function testWriteln(): void
{
$this->symfonyStyle->method('getErrorStyle')->willReturnSelf();
- $this->symfonyStyle->expects(self::once())->method('writeln')->with('test');
+ $this->symfonyStyle->expects($this->once())->method('writeln')->with('test');
$this->errorOutput->writeln('test');
}
}
diff --git a/tests/unit/Cli/MetricsCommandTest.php b/tests/unit/Cli/MetricsCommandTest.php
index 9821316..15dc5ef 100644
--- a/tests/unit/Cli/MetricsCommandTest.php
+++ b/tests/unit/Cli/MetricsCommandTest.php
@@ -53,7 +53,7 @@ public function testPrintsMetrics(): void
$output = new BufferedOutput();
$this->metricsCommand->run($this->input, $output);
- assertEquals(
+ $this->assertEquals(
'+--------------------+-------+
| Classes: | 1 |
| Abstract classes: | 2 |
diff --git a/tests/unit/Cli/TextCommandTest.php b/tests/unit/Cli/TextCommandTest.php
index 58a9ef6..c8e20ca 100644
--- a/tests/unit/Cli/TextCommandTest.php
+++ b/tests/unit/Cli/TextCommandTest.php
@@ -52,7 +52,7 @@ public function testPrintsDependencies(): void
$this->input->method('getOption')->willReturn(false, 0);
$this->input->method('getOptions')->willReturn(['internals' => false, 'filter-namespace' => null, 'depth' => 0]);
- $this->output->expects(once())
+ $this->output->expects($this->once())
->method('writeln')
->with(
'A\\a\\1\\ClassA --> B\\a\\1\\ClassB'.PHP_EOL
@@ -75,7 +75,7 @@ public function testPrintsOnlyNamespacedDependencies(): void
$this->input->method('getArgument')->willReturn([sys_get_temp_dir()]);
$this->input->method('getOptions')->willReturn(['internals' => false, 'filter-namespace' => null, 'depth' => 1]);
- $this->output->expects(once())
+ $this->output->expects($this->once())
->method('writeln')
->with(
'NamespaceA --> NamespaceB'.PHP_EOL
diff --git a/tests/unit/Cli/UmlCommandTest.php b/tests/unit/Cli/UmlCommandTest.php
index 9197b50..140fc7f 100644
--- a/tests/unit/Cli/UmlCommandTest.php
+++ b/tests/unit/Cli/UmlCommandTest.php
@@ -86,7 +86,7 @@ public function testGenerateUml(): void
'filter-namespace' => null,
'depth' => 0
]);
- $this->plantUmlWrapper->expects(once())->method('generate');
+ $this->plantUmlWrapper->expects($this->once())->method('generate');
$this->umlCommand->run(
$this->input,
diff --git a/tests/unit/Dependencies/ClazzTest.php b/tests/unit/Dependencies/ClazzTest.php
index 8d271ab..d3a9b1e 100644
--- a/tests/unit/Dependencies/ClazzTest.php
+++ b/tests/unit/Dependencies/ClazzTest.php
@@ -18,58 +18,58 @@ class ClazzTest extends TestCase
{
public function testAcceptsUtf8Name(): void
{
- assertEquals('á', (new Clazz('á'))->toString());
+ $this->assertEquals('á', (new Clazz('á'))->toString());
}
public function testHasValue(): void
{
- assertEquals('Name', new Clazz('Name'));
- assertEquals('Name', (new Clazz('Name'))->toString());
+ $this->assertEquals('Name', new Clazz('Name'));
+ $this->assertEquals('Name', (new Clazz('Name'))->toString());
}
public function testNamespace(): void
{
- assertEquals(new Namespaze(['A', 'a']), (new Clazz('Name', new Namespaze(['A', 'a'])))->namespaze());
+ $this->assertEquals(new Namespaze(['A', 'a']), (new Clazz('Name', new Namespaze(['A', 'a'])))->namespaze());
}
public function testToStringWithNamespace(): void
{
- assertEquals('A\\a\\ClassA', new Clazz('ClassA', new Namespaze(['A', 'a'])));
+ $this->assertEquals('A\\a\\ClassA', new Clazz('ClassA', new Namespaze(['A', 'a'])));
}
public function testEquals(): void
{
- assertTrue((new Clazz('A'))->equals(new Clazz('A')));
+ $this->assertTrue((new Clazz('A'))->equals(new Clazz('A')));
}
public function testEqualsIgnoresType(): void
{
- assertTrue((new Clazz('A'))->equals(new Interfaze('A')));
+ $this->assertTrue((new Clazz('A'))->equals(new Interfaze('A')));
}
public function testDetectsIfClassHasNamespace(): void
{
- assertTrue((new Clazz('Class', new Namespaze(['A'])))->hasNamespace());
+ $this->assertTrue((new Clazz('Class', new Namespaze(['A'])))->hasNamespace());
}
public function testDetectsIfClassHasNoNamespace(): void
{
- assertFalse((new Clazz('Class'))->hasNamespace());
+ $this->assertFalse((new Clazz('Class'))->hasNamespace());
}
public function testDepthWithoutNamespaceIsOne(): void
{
- assertCount(1, new Clazz('A'));
+ $this->assertCount(1, new Clazz('A'));
}
public function testDepthWithNamespace(): void
{
- assertCount(3, new Clazz('A', new Namespaze(['B', 'C'])));
+ $this->assertCount(3, new Clazz('A', new Namespaze(['B', 'C'])));
}
public function testReduceWithDepthZero(): void
{
- assertEquals(
+ $this->assertEquals(
H::clazz('A\\B\\C\\D'),
H::clazz('A\\B\\C\\D')->reduceToDepth(0)
);
@@ -77,13 +77,13 @@ public function testReduceWithDepthZero(): void
public function testReduceToDepthTwoWithoutNamespacesProducesClass(): void
{
- assertEquals(new Clazz('A'), (new Clazz('A'))->reduceToDepth(2));
+ $this->assertEquals(new Clazz('A'), (new Clazz('A'))->reduceToDepth(2));
}
public function testReduceDepthToTwoProducesTopTwoNamespaces(): void
{
$clazz = H::clazz('A\\B\\C\\D');
- assertEquals(
+ $this->assertEquals(
new Namespaze(['A', 'B']),
$clazz->reduceToDepth(2)
);
@@ -91,7 +91,7 @@ public function testReduceDepthToTwoProducesTopTwoNamespaces(): void
public function testReduceToDepthOfOneProducesOneNamespace(): void
{
- assertEquals(
+ $this->assertEquals(
new Namespaze(['A']),
H::clazz('A\\B\\C\\D')->reduceToDepth(1)
);
@@ -99,7 +99,7 @@ public function testReduceToDepthOfOneProducesOneNamespace(): void
public function testLeftReduceClassWithNamespace(): void
{
- assertEquals(
+ $this->assertEquals(
H::clazz('D'),
H::clazz('A\\B\\C\\D')->reduceDepthFromLeftBy(3)
);
@@ -107,7 +107,7 @@ public function testLeftReduceClassWithNamespace(): void
public function testCannotLeftReduceClassWithNamespaceByItsLength(): void
{
- assertEquals(
+ $this->assertEquals(
H::clazz('A\\B\\C\\D'),
H::clazz('A\\B\\C\\D')->reduceDepthFromLeftBy(4)
);
@@ -118,12 +118,12 @@ public function testCannotLeftReduceClassWithNamespaceByItsLength(): void
*/
public function testAcceptsNumbersAsFirstCharacterInName(): void
{
- assertEquals('Vendor\\1Sub\\2Factor', new Clazz('2Factor', new Namespaze(['Vendor', '1Sub'])));
+ $this->assertEquals('Vendor\\1Sub\\2Factor', new Clazz('2Factor', new Namespaze(['Vendor', '1Sub'])));
}
public function testCannotLeftReduceClassWithNamespaceByMoreThanItsLength(): void
{
- assertEquals(
+ $this->assertEquals(
H::clazz('A\\B\\C\\D'),
H::clazz('A\\B\\C\\D')->reduceDepthFromLeftBy(5)
);
@@ -131,14 +131,14 @@ public function testCannotLeftReduceClassWithNamespaceByMoreThanItsLength(): voi
public function testDetectsIfInOtherNamespace(): void
{
- assertTrue(DependencyHelper::clazz('A\\b\\T\\Test')->inNamespaze(DependencyHelper::namespaze('A\\b')));
- assertTrue(DependencyHelper::clazz('A\\Test')->inNamespaze(DependencyHelper::namespaze('A')));
- assertTrue(DependencyHelper::clazz(Collection::class)->inNamespaze(new Namespaze(['Mihaeu', 'PhpDependencies'])));
+ $this->assertTrue(DependencyHelper::clazz('A\\b\\T\\Test')->inNamespaze(DependencyHelper::namespaze('A\\b')));
+ $this->assertTrue(DependencyHelper::clazz('A\\Test')->inNamespaze(DependencyHelper::namespaze('A')));
+ $this->assertTrue(DependencyHelper::clazz(Collection::class)->inNamespaze(new Namespaze(['Mihaeu', 'PhpDependencies'])));
}
public function testDetectsIfNotInOtherNamespace(): void
{
- assertFalse(DependencyHelper::clazz('Global')->inNamespaze(DependencyHelper::namespaze('A\\b\\T')));
+ $this->assertFalse(DependencyHelper::clazz('Global')->inNamespaze(DependencyHelper::namespaze('A\\b\\T')));
}
public function testThrowsExceptionIfNameNotValid(): void
@@ -150,11 +150,11 @@ public function testThrowsExceptionIfNameNotValid(): void
public function testDetectsIfClassIsNotNamespaced(): void
{
- assertFalse((new Clazz('NoNamespace'))->isNamespaced());
+ $this->assertFalse((new Clazz('NoNamespace'))->isNamespaced());
}
public function testDetectsIfClassIsNamespaced(): void
{
- assertTrue((new Clazz('HasNamespace', new Namespaze(['Vendor'])))->isNamespaced());
+ $this->assertTrue((new Clazz('HasNamespace', new Namespaze(['Vendor'])))->isNamespaced());
}
}
diff --git a/tests/unit/Dependencies/DependencyFactoryTest.php b/tests/unit/Dependencies/DependencyFactoryTest.php
index 1a02dde..bf231ec 100644
--- a/tests/unit/Dependencies/DependencyFactoryTest.php
+++ b/tests/unit/Dependencies/DependencyFactoryTest.php
@@ -21,7 +21,7 @@ protected function setUp(): void
public function testInvalidClassReturnsNullDependency(): void
{
- assertInstanceOf(
+ $this->assertInstanceOf(
NullDependency::class,
$this->clazzFactory->createClazzFromStringArray(['/'])
);
@@ -29,12 +29,12 @@ public function testInvalidClassReturnsNullDependency(): void
public function testCreatesClazzWithEmptyNamespace(): void
{
- assertEquals(new Clazz('Test', new Namespaze([])), $this->clazzFactory->createClazzFromStringArray(['Test']));
+ $this->assertEquals(new Clazz('Test', new Namespaze([])), $this->clazzFactory->createClazzFromStringArray(['Test']));
}
public function testCreateClazzWithNamespace(): void
{
- assertEquals(
+ $this->assertEquals(
new Clazz('Test', new Namespaze(['Mihaeu', 'PhpDependencies'])),
$this->clazzFactory->createClazzFromStringArray(['Mihaeu', 'PhpDependencies', 'Test'])
);
@@ -42,16 +42,16 @@ public function testCreateClazzWithNamespace(): void
public function testCreateInterfaze(): void
{
- assertEquals(new AbstractClazz('Test', new Namespaze([])), $this->clazzFactory->createAbstractClazzFromStringArray(['Test']));
+ $this->assertEquals(new AbstractClazz('Test', new Namespaze([])), $this->clazzFactory->createAbstractClazzFromStringArray(['Test']));
}
public function testCreateAbstractClazz(): void
{
- assertEquals(new Interfaze('Test', new Namespaze([])), $this->clazzFactory->createInterfazeFromStringArray(['Test']));
+ $this->assertEquals(new Interfaze('Test', new Namespaze([])), $this->clazzFactory->createInterfazeFromStringArray(['Test']));
}
public function testCreateTrait(): void
{
- assertEquals(new Trait_('Test', new Namespaze([])), $this->clazzFactory->createTraitFromStringArray(['Test']));
+ $this->assertEquals(new Trait_('Test', new Namespaze([])), $this->clazzFactory->createTraitFromStringArray(['Test']));
}
}
diff --git a/tests/unit/Dependencies/DependencyFilterTest.php b/tests/unit/Dependencies/DependencyFilterTest.php
index 1e5cdc6..d4e0a37 100644
--- a/tests/unit/Dependencies/DependencyFilterTest.php
+++ b/tests/unit/Dependencies/DependencyFilterTest.php
@@ -25,7 +25,7 @@ public function testRemovesInternals(): void
{
$dependencies = DependencyHelper::map('From --> To, SplFileInfo');
$expected = (new DependencyMap())->add(new Clazz('From'), new Clazz('To'));
- assertEquals($expected, $this->filter->removeInternals($dependencies));
+ $this->assertEquals($expected, $this->filter->removeInternals($dependencies));
}
public function testFilterByDepthOne(): void
@@ -39,12 +39,12 @@ public function testFilterByDepthOne(): void
_B --> SplFileInfo
');
$actual = $this->filter->filterByDepth($dependencies, 1);
- assertEquals($expected, $actual);
+ $this->assertEquals($expected, $actual);
}
public function testMapUnderscoreNamespaces(): void
{
- assertEquals(
+ $this->assertEquals(
DependencyHelper::map('
A\\b\\c --> D\\e\\f
F\\a --> D\\b
@@ -58,7 +58,7 @@ public function testMapUnderscoreNamespaces(): void
public function testMapUnderscoreNamespacesAlreadyNamespace(): void
{
- assertEquals(
+ $this->assertEquals(
DependencyHelper::map('
VendorA\\Tests\\DDC1209_1 --> a\\To
A\\__b__\\c --> D\\e\\f
@@ -77,7 +77,7 @@ public function testFilterByDepthThree(): void
');
$expected = DependencyHelper::map('_VendorA\\ProjectA\\PathA --> _VendorB\\ProjectB\\PathB');
$actual = $this->filter->filterByDepth($dependencies, 3);
- assertEquals($expected, $actual);
+ $this->assertEquals($expected, $actual);
}
public function testFilterByVendor(): void
@@ -90,7 +90,7 @@ public function testFilterByVendor(): void
$expected = DependencyHelper::map('
VendorA\\A --> VendorA\\C
');
- assertEquals($expected, $this->filter->filterByNamespace($dependencies, 'VendorA'));
+ $this->assertEquals($expected, $this->filter->filterByNamespace($dependencies, 'VendorA'));
}
public function testFilterByDepth0ReturnsEqual(): void
@@ -101,7 +101,7 @@ public function testFilterByDepth0ReturnsEqual(): void
VendorB\\B --> VendorA\\A
VendorC\\C --> VendorA\\A
');
- assertEquals($dependencies, $this->filter->filterByDepth($dependencies, 0));
+ $this->assertEquals($dependencies, $this->filter->filterByDepth($dependencies, 0));
}
public function testRemoveClasses(): void
{
@@ -114,12 +114,12 @@ public function testRemoveClasses(): void
VendorB\\B --> VendorA\\A
VendorC\\C --> B
'));
- assertEquals($expected, $actual);
+ $this->assertEquals($expected, $actual);
}
public function testFilterFromDependencies(): void
{
- assertEquals(DependencyHelper::map('
+ $this->assertEquals(DependencyHelper::map('
Good\\A --> Bad\\B
Good\\B --> Good\\C
'), $this->filter->filterByFromNamespace(DependencyHelper::map('
@@ -166,12 +166,12 @@ public function testRunAllFilters(): void
A\\a\\z --> A\\b\\z
A\\b\\c --> A\\b\\z
');
- assertEquals($expected, $actual);
+ $this->assertEquals($expected, $actual);
}
public function testExcludeByRegex(): void
{
- assertEquals(DependencyHelper::map('
+ $this->assertEquals(DependencyHelper::map('
X --> Z
'), $this->filter->excludeByRegex(DependencyHelper::map('
Test\\A --> B
@@ -186,6 +186,6 @@ public function testExcludeByRegex(): void
public function testPostFilters(): void
{
$filters = $this->filter->postFiltersByOptions(['no-classes' => true, 'depth' => 1]);
- assertEquals(new Namespaze(['A']), $filters(new Clazz('Test', new Namespaze(['A', 'a']))));
+ $this->assertEquals(new Namespaze(['A']), $filters(new Clazz('Test', new Namespaze(['A', 'a']))));
}
}
diff --git a/tests/unit/Dependencies/DependencyMapTest.php b/tests/unit/Dependencies/DependencyMapTest.php
index 1200176..7591c33 100644
--- a/tests/unit/Dependencies/DependencyMapTest.php
+++ b/tests/unit/Dependencies/DependencyMapTest.php
@@ -19,12 +19,12 @@ public function testNoDuplicates(): void
A --> B
B --> C
');
- assertEquals($map, $map->add(new Clazz('A'), new Clazz('B')));
+ $this->assertEquals($map, $map->add(new Clazz('A'), new Clazz('B')));
}
public function testAddMapToMap(): void
{
- assertEquals(DependencyHelper::map('
+ $this->assertEquals(DependencyHelper::map('
A --> B, C
B --> C
'), DependencyHelper::map('
@@ -38,7 +38,7 @@ public function testAddMapToMap(): void
public function testAddMoreDependenciesToExistingPair(): void
{
$map = DependencyHelper::map('A --> B');
- assertEquals(
+ $this->assertEquals(
DependencyHelper::map('A --> B, C, D'),
$map->addSet(new Clazz('A'), DependencyHelper::dependencySet('C, D'))
);
@@ -46,14 +46,14 @@ public function testAddMoreDependenciesToExistingPair(): void
public function testDoesNotAcceptDependenciesMappingToThemselves(): void
{
- assertCount(0, DependencyHelper::map('')->add(new Clazz('A'), new Clazz('A')));
+ $this->assertCount(0, DependencyHelper::map('')->add(new Clazz('A'), new Clazz('A')));
}
public function testReturnsTrueIfAnyMatches(): void
{
$toSet = DependencyHelper::dependencySet('To, ToAnother');
$dependencies = (new DependencyMap())->addSet(new Clazz('Test'), $toSet);
- assertTrue($dependencies->any(function (Dependency $from, Dependency $to) use ($toSet) {
+ $this->assertTrue($dependencies->any(function (Dependency $from, Dependency $to) use ($toSet) {
return $toSet->contains($to);
}));
}
@@ -61,7 +61,7 @@ public function testReturnsTrueIfAnyMatches(): void
public function testReturnsTrueIfNoneMatches(): void
{
$dependencies = (new DependencyMap())->addSet(new Clazz('Test'), DependencyHelper::dependencySet('To, ToAnother'));
- assertTrue($dependencies->none(function (Dependency $from, Dependency $to) {
+ $this->assertTrue($dependencies->none(function (Dependency $from, Dependency $to) {
return $from === new Clazz('Other');
}));
}
@@ -69,14 +69,14 @@ public function testReturnsTrueIfNoneMatches(): void
public function testEach(): void
{
DependencyHelper::map('From --> To, ToAnother')->each(function (Dependency $from, Dependency $to) {
- assertTrue($from->equals(new Clazz('From')));
+ $this->assertTrue($from->equals(new Clazz('From')));
});
}
public function testReduce(): void
{
$dependencies = DependencyHelper::map('From --> To, ToAnother');
- assertEquals('ToToAnother', $dependencies->reduce('', function (string $output, Dependency $from, Dependency $to) {
+ $this->assertEquals('ToToAnother', $dependencies->reduce('', function (string $output, Dependency $from, Dependency $to) {
return $output.$to->toString();
}));
}
@@ -85,19 +85,19 @@ public function testFromClasses(): void
{
$dependencies = DependencyHelper::map('From --> To, ToAnother');
$expected = (new DependencySet())->add(new Clazz('From'));
- assertEquals($expected, $dependencies->fromDependencies());
+ $this->assertEquals($expected, $dependencies->fromDependencies());
}
public function testAllClasses(): void
{
$dependencies = DependencyHelper::map('From --> To, ToAnother');
$expected = DependencyHelper::dependencySet('From, To, ToAnother');
- assertEquals($expected, $dependencies->allDependencies());
+ $this->assertEquals($expected, $dependencies->allDependencies());
}
public function testToString(): void
{
- assertEquals(
+ $this->assertEquals(
'VendorA\\A --> VendorB\\A'.PHP_EOL
.'VendorA\\A --> VendorA\\C'.PHP_EOL
.'VendorB\\B --> VendorA\\A'.PHP_EOL
@@ -112,7 +112,7 @@ public function testToString(): void
public function testMapToArray(): void
{
- assertEquals([new Clazz('A'), new Clazz('C')], DependencyHelper::map('
+ $this->assertEquals([new Clazz('A'), new Clazz('C')], DependencyHelper::map('
A --> B
C --> D
')->mapToArray(function (Dependency $from, Dependency $to) {
@@ -122,7 +122,7 @@ public function testMapToArray(): void
public function testToArray(): void
{
- assertEquals([
+ $this->assertEquals([
'A' => [
'key' => new Clazz('A'),
'value' => (new DependencySet())->add(new Clazz('B')),
@@ -139,7 +139,7 @@ public function testToArray(): void
public function testFilter(): void
{
- assertEquals(
+ $this->assertEquals(
DependencyHelper::map('A --> B'),
DependencyHelper::map('
A --> B
@@ -152,7 +152,7 @@ public function testFilter(): void
public function testCount(): void
{
- assertCount(2, DependencyHelper::map('
+ $this->assertCount(2, DependencyHelper::map('
A --> B, C, D
D --> E
'));
@@ -168,12 +168,12 @@ public function testEquals(): void
A --> B, C, D
D --> E
')->add(new Clazz('D'), new Clazz('E'));
- assertTrue($one->equals($two));
+ $this->assertTrue($one->equals($two));
}
public function testContainsIsTrueIfItMatchesTheKey(): void
{
- assertTrue(DependencyHelper::map('
+ $this->assertTrue(DependencyHelper::map('
A --> B, C, D
D --> E
')->contains(new Clazz('A')));
@@ -181,7 +181,7 @@ public function testContainsIsTrueIfItMatchesTheKey(): void
public function testContainsIsFalseIfItOnlyMatchesTheValue(): void
{
- assertFalse(DependencyHelper::map('
+ $this->assertFalse(DependencyHelper::map('
A --> B, C, D
D --> E
')->contains(new Clazz('E')));
@@ -193,14 +193,14 @@ public function testMapAllDependencies(): void
A\b --> C
Y --> Z\d
');
- assertEquals(DependencyHelper::dependencySet('_A, _Z'), $map->mapAllDependencies(function (Dependency $dependency) {
+ $this->assertEquals(DependencyHelper::dependencySet('_A, _Z'), $map->mapAllDependencies(function (Dependency $dependency) {
return $dependency->namespaze();
}));
}
public function testGet(): void
{
- assertEquals(
+ $this->assertEquals(
DependencyHelper::dependencySet('A, B, C'),
DependencyHelper::map('D --> A, B, C')->get(new Clazz('D'))
);
@@ -208,7 +208,7 @@ public function testGet(): void
public function testReduceEachDependency(): void
{
- assertEquals(DependencyHelper::map('
+ $this->assertEquals(DependencyHelper::map('
_A --> _B, _C
'), DependencyHelper::map('
A\b --> B\d, C\d
@@ -221,28 +221,28 @@ public function testReduceEachDependency(): void
public function testDoesNotPrintNullDependenciesInKey(): void
{
$map = (new DependencyMap())->add(new NullDependency(), new Clazz('A'));
- assertEmpty($map->toString());
+ $this->assertEmpty($map->toString());
}
public function testDoesNotPrintNullDependenciesInValue(): void
{
$map = (new DependencyMap())->add(new Clazz('A'), new NullDependency());
- assertEmpty($map->toString());
+ $this->assertEmpty($map->toString());
}
public function testCannotAddEmptyNamespaceAsFrom(): void
{
- assertEmpty((new DependencyMap())->add(new Clazz('A'), new Namespaze([])));
+ $this->assertEmpty((new DependencyMap())->add(new Clazz('A'), new Namespaze([])));
}
public function testCannotAddEmptyNamespaceAsTo(): void
{
- assertEmpty((new DependencyMap())->add(new Namespaze([]), new Clazz('A')));
+ $this->assertEmpty((new DependencyMap())->add(new Namespaze([]), new Clazz('A')));
}
public function testCannotAddSelf(): void
{
- assertEmpty((new DependencyMap())->add(new Clazz('A'), new Clazz('self')));
+ $this->assertEmpty((new DependencyMap())->add(new Clazz('A'), new Clazz('self')));
}
public function testCannotAddDependencyToYourself(): void
@@ -256,6 +256,6 @@ public function testCannotAddDependencyToYourself(): void
new Clazz('A'),
new Clazz('static')
);
- assertEmpty($dependencyMap);
+ $this->assertEmpty($dependencyMap);
}
}
diff --git a/tests/unit/Dependencies/DependencySetTest.php b/tests/unit/Dependencies/DependencySetTest.php
index 573dcb3..d2ec993 100644
--- a/tests/unit/Dependencies/DependencySetTest.php
+++ b/tests/unit/Dependencies/DependencySetTest.php
@@ -18,7 +18,7 @@ public function testAdd(): void
$clazzCollection = (new DependencySet())
->add(new Clazz('Test'));
$clazzCollection->each(function (Dependency $clazz) {
- assertEquals(new Clazz('Test'), $clazz);
+ $this->assertEquals(new Clazz('Test'), $clazz);
});
}
@@ -27,21 +27,21 @@ public function testIsImmutable(): void
$clazzCollection = (new DependencySet())
->add(new Clazz('Test'));
$newCollectionAfterRefusingDuplicate = $clazzCollection->add(new Clazz('Test'));
- assertNotSame($clazzCollection, $newCollectionAfterRefusingDuplicate);
+ $this->assertNotSame($clazzCollection, $newCollectionAfterRefusingDuplicate);
}
public function testDoesNotAcceptDuplicates(): void
{
$clazzCollection = (new DependencySet())
->add(new Clazz('Test'));
- assertEquals($clazzCollection, $clazzCollection->add(new Clazz('Test')));
+ $this->assertEquals($clazzCollection, $clazzCollection->add(new Clazz('Test')));
}
public function testToArray(): void
{
$clazzCollection = (new DependencySet())
->add(new Clazz('Test'));
- assertEquals([new Clazz('Test')], $clazzCollection->toArray());
+ $this->assertEquals([new Clazz('Test')], $clazzCollection->toArray());
}
public function testToString(): void
@@ -49,34 +49,34 @@ public function testToString(): void
$clazzCollection = (new DependencySet())
->add(new Clazz('Test'))
->add(new Clazz('Test2'));
- assertEquals('Test'.PHP_EOL.'Test2', $clazzCollection->__toString());
+ $this->assertEquals('Test'.PHP_EOL.'Test2', $clazzCollection->__toString());
}
public function testFilter(): void
{
$expected = DependencyHelper::dependencySet('AB, AC');
- assertEquals($expected, DependencyHelper::dependencySet('AB, AC, BA, CA')->filter(function (Dependency $dependency) {
+ $this->assertEquals($expected, DependencyHelper::dependencySet('AB, AC, BA, CA')->filter(function (Dependency $dependency) {
return strpos($dependency->toString(), 'A') === 0;
}));
}
public function testReduce(): void
{
- assertEquals('ABC', DependencyHelper::dependencySet('A, B, C')->reduce('', function (string $carry, Dependency $dependency) {
+ $this->assertEquals('ABC', DependencyHelper::dependencySet('A, B, C')->reduce('', function (string $carry, Dependency $dependency) {
return $carry.$dependency->toString();
}));
}
public function testNoneIsTrueWhenNoneMatches(): void
{
- assertTrue(DependencyHelper::dependencySet('AB, AC, BA, CA')->none(function (Dependency $dependency) {
+ $this->assertTrue(DependencyHelper::dependencySet('AB, AC, BA, CA')->none(function (Dependency $dependency) {
return strpos($dependency->toString(), 'D') === 0;
}));
}
public function testNoneIsFalseWhenSomeMatch(): void
{
- assertFalse(DependencyHelper::dependencySet('AB, AC, BA, CA')->none(function (Dependency $dependency) {
+ $this->assertFalse(DependencyHelper::dependencySet('AB, AC, BA, CA')->none(function (Dependency $dependency) {
return strpos($dependency->toString(), 'A') === 0;
}));
}
diff --git a/tests/unit/Dependencies/NamespazeTest.php b/tests/unit/Dependencies/NamespazeTest.php
index 09b4e41..52fa4f6 100644
--- a/tests/unit/Dependencies/NamespazeTest.php
+++ b/tests/unit/Dependencies/NamespazeTest.php
@@ -14,12 +14,12 @@ class NamespazeTest extends TestCase
{
public function testAcceptsEmptyNamespace(): void
{
- assertEquals('', new Namespaze([]));
+ $this->assertEquals('', new Namespaze([]));
}
public function testAcceptsValidNamespaceParts(): void
{
- assertEquals('a\b\c', new Namespaze(['a', 'b', 'c']));
+ $this->assertEquals('a\b\c', new Namespaze(['a', 'b', 'c']));
}
public function testDetectsInvalidNamespaceParts(): void
@@ -30,78 +30,78 @@ public function testDetectsInvalidNamespaceParts(): void
public function testDepthOfEmptyNamespaceIsZero(): void
{
- assertCount(0, new Namespaze([]));
+ $this->assertCount(0, new Namespaze([]));
}
public function testDepthOfNamespace(): void
{
- assertCount(2, new Namespaze(['A', 'B']));
+ $this->assertCount(2, new Namespaze(['A', 'B']));
}
public function testReducingDepthLowerThanPossibleProducesNullDependency(): void
{
- assertInstanceOf(NullDependency::class, (new Namespaze(['Test']))->reduceToDepth(3));
+ $this->assertInstanceOf(NullDependency::class, (new Namespaze(['Test']))->reduceToDepth(3));
}
public function testReduceToMaxDepth(): void
{
- assertEquals(new Namespaze(['A', 'B']), (new Namespaze(['A', 'B', 'C', 'D']))->reduceToDepth(2));
+ $this->assertEquals(new Namespaze(['A', 'B']), (new Namespaze(['A', 'B', 'C', 'D']))->reduceToDepth(2));
}
public function testDoNotReduceForMaxDepthZero(): void
{
- assertEquals(new Namespaze(['A', 'B']), (new Namespaze(['A', 'B']))->reduceToDepth(0));
+ $this->assertEquals(new Namespaze(['A', 'B']), (new Namespaze(['A', 'B']))->reduceToDepth(0));
}
public function testLeftReduceNamespace(): void
{
- assertEquals(new Namespaze(['C']), (new Namespaze(['A', 'B', 'C']))->reduceDepthFromLeftBy(2));
+ $this->assertEquals(new Namespaze(['C']), (new Namespaze(['A', 'B', 'C']))->reduceDepthFromLeftBy(2));
}
public function testReduceSameAsLengthProducesEmptyNamespace(): void
{
- assertEquals(new Namespaze([]), (new Namespaze(['A', 'B', 'C']))->reduceDepthFromLeftBy(3));
+ $this->assertEquals(new Namespaze([]), (new Namespaze(['A', 'B', 'C']))->reduceDepthFromLeftBy(3));
}
public function testReduceMoreThanLengthProducesEmptyNamespace(): void
{
- assertEquals(new Namespaze([]), (new Namespaze(['A', 'B', 'C']))->reduceDepthFromLeftBy(5));
+ $this->assertEquals(new Namespaze([]), (new Namespaze(['A', 'B', 'C']))->reduceDepthFromLeftBy(5));
}
public function testEquals(): void
{
- assertTrue((new Namespaze(['A', 'B']))->equals(new Namespaze(['A', 'B'])));
- assertTrue((new Namespaze([]))->equals(new Namespaze([])));
- assertFalse((new Namespaze(['A', 'B']))->equals(new Namespaze(['A'])));
- assertFalse((new Namespaze(['A', 'B']))->equals(new Namespaze([])));
+ $this->assertTrue((new Namespaze(['A', 'B']))->equals(new Namespaze(['A', 'B'])));
+ $this->assertTrue((new Namespaze([]))->equals(new Namespaze([])));
+ $this->assertFalse((new Namespaze(['A', 'B']))->equals(new Namespaze(['A'])));
+ $this->assertFalse((new Namespaze(['A', 'B']))->equals(new Namespaze([])));
}
public function testPartsByIndex(): void
{
- assertEquals(new Namespaze(['1']), (new Namespaze(['1', '2']))->parts()[0]);
- assertEquals(new Namespaze(['2']), (new Namespaze(['1', '2']))->parts()[1]);
+ $this->assertEquals(new Namespaze(['1']), (new Namespaze(['1', '2']))->parts()[0]);
+ $this->assertEquals(new Namespaze(['2']), (new Namespaze(['1', '2']))->parts()[1]);
}
public function testNamespazeReturnsItself(): void
{
- assertEquals(new Namespaze(['1', '2']), (new Namespaze(['1', '2']))->namespaze());
+ $this->assertEquals(new Namespaze(['1', '2']), (new Namespaze(['1', '2']))->namespaze());
}
public function testDetectsIfInOtherNamespace(): void
{
- assertTrue((new Namespaze(['A', 'b', 'T']))->inNamespaze(new Namespaze(['A', 'b', 'T'])));
- assertTrue((new Namespaze(['A', 'b', 'T']))->inNamespaze(new Namespaze(['A'])));
+ $this->assertTrue((new Namespaze(['A', 'b', 'T']))->inNamespaze(new Namespaze(['A', 'b', 'T'])));
+ $this->assertTrue((new Namespaze(['A', 'b', 'T']))->inNamespaze(new Namespaze(['A'])));
}
public function testDetectsIfNotInOtherNamespace(): void
{
- assertFalse((new Namespaze(['XZY', 'b', 'T']))->inNamespaze(new Namespaze(['A', 'b', 'T'])));
- assertFalse((new Namespaze([]))->inNamespaze(new Namespaze(['A', 'b', 'T'])));
- assertFalse((new Namespaze(['XZY', 'b', 'T']))->inNamespaze(new Namespaze([])));
+ $this->assertFalse((new Namespaze(['XZY', 'b', 'T']))->inNamespaze(new Namespaze(['A', 'b', 'T'])));
+ $this->assertFalse((new Namespaze([]))->inNamespaze(new Namespaze(['A', 'b', 'T'])));
+ $this->assertFalse((new Namespaze(['XZY', 'b', 'T']))->inNamespaze(new Namespaze([])));
}
public function testEmptyNamespaceIsNotNamespaced(): void
{
- assertFalse((new Namespaze([]))->isNamespaced());
+ $this->assertFalse((new Namespaze([]))->isNamespaced());
}
}
diff --git a/tests/unit/Dependencies/NullDependencyTest.php b/tests/unit/Dependencies/NullDependencyTest.php
index dc60cc7..1330fcf 100644
--- a/tests/unit/Dependencies/NullDependencyTest.php
+++ b/tests/unit/Dependencies/NullDependencyTest.php
@@ -13,46 +13,46 @@ class NullDependencyTest extends TestCase
{
public function testReduceToDepth(): void
{
- assertEquals(new NullDependency(), (new NullDependency())->reduceToDepth(99));
+ $this->assertEquals(new NullDependency(), (new NullDependency())->reduceToDepth(99));
}
public function testReduceDepthFromLeftBy(): void
{
- assertEquals(new NullDependency(), (new NullDependency())->reduceDepthFromLeftBy(99));
+ $this->assertEquals(new NullDependency(), (new NullDependency())->reduceDepthFromLeftBy(99));
}
public function testEquals(): void
{
- assertFalse((new NullDependency())->equals(new NullDependency()));
+ $this->assertFalse((new NullDependency())->equals(new NullDependency()));
}
public function testToString(): void
{
- assertEquals('', (new NullDependency())->__toString());
+ $this->assertEquals('', (new NullDependency())->__toString());
}
public function testNamespaze(): void
{
- assertEquals(new Namespaze([]), (new NullDependency())->namespaze());
+ $this->assertEquals(new Namespaze([]), (new NullDependency())->namespaze());
}
public function testInNamespazeIsFalseForEmptyNamespace(): void
{
- assertFalse((new NullDependency())->inNamespaze(new Namespaze([])));
+ $this->assertFalse((new NullDependency())->inNamespaze(new Namespaze([])));
}
public function testInNamespazeIsFalseForEveryNamespace(): void
{
- assertFalse((new NullDependency())->inNamespaze(new Namespaze(['A'])));
+ $this->assertFalse((new NullDependency())->inNamespaze(new Namespaze(['A'])));
}
public function testCountIsAlwaysZero(): void
{
- assertCount(0, new NullDependency());
+ $this->assertCount(0, new NullDependency());
}
public function testIsNotNamespaced(): void
{
- assertFalse((new NullDependency())->isNamespaced());
+ $this->assertFalse((new NullDependency())->isNamespaced());
}
}
diff --git a/tests/unit/DependencyHelperTest.php b/tests/unit/DependencyHelperTest.php
index 7c202b9..13d9107 100644
--- a/tests/unit/DependencyHelperTest.php
+++ b/tests/unit/DependencyHelperTest.php
@@ -24,7 +24,7 @@ public function testConvert(): void
new Clazz('DepC', new Namespaze(['C'])),
new Clazz('DepD', new Namespaze(['D']))
);
- assertEquals($expected, DependencyHelper::map('
+ $this->assertEquals($expected, DependencyHelper::map('
A\\DepA --> B\\DepB
C\\DepC --> D\\DepD
'));
@@ -39,7 +39,7 @@ public function testConvertMultipleDependencies(): void
new Clazz('DepA', new Namespaze(['A'])),
new Clazz('DepD', new Namespaze(['D']))
);
- assertEquals($expected, DependencyHelper::map('
+ $this->assertEquals($expected, DependencyHelper::map('
A\\DepA --> B\\DepB, D\\DepD
'));
}
diff --git a/tests/unit/Formatters/DependencyStructureMatrixBuilderTest.php b/tests/unit/Formatters/DependencyStructureMatrixBuilderTest.php
index 93cf730..49e9310 100644
--- a/tests/unit/Formatters/DependencyStructureMatrixBuilderTest.php
+++ b/tests/unit/Formatters/DependencyStructureMatrixBuilderTest.php
@@ -27,7 +27,7 @@ public function testBuildMatrixFromClassesWithoutNamespaces(): void
C --> A
D --> B
');
- assertEquals([
+ $this->assertEquals([
'A' => ['A' => 0, 'B' => 0, 'C' => 1, 'D' => 0],
'B' => ['A' => 1, 'B' => 0, 'C' => 0, 'D' => 1],
'C' => ['A' => 0, 'B' => 0, 'C' => 0, 'D' => 0],
@@ -43,7 +43,7 @@ public function testBuildMatrixFromClassesWithNamespaces(): void
CC\\C --> AA\\A
DD\\D --> BB\\B
');
- assertEquals([
+ $this->assertEquals([
'AA\\A' => ['AA\\A' => 0, 'BB\\B' => 0, 'CC\\C' => 1, 'DD\\D' => 0],
'BB\\B' => ['AA\\A' => 1, 'BB\\B' => 0, 'CC\\C' => 0, 'DD\\D' => 1],
'CC\\C' => ['AA\\A' => 0, 'BB\\B' => 0, 'CC\\C' => 0, 'DD\\D' => 0],
diff --git a/tests/unit/Formatters/DotFormatterTest.php b/tests/unit/Formatters/DotFormatterTest.php
index 5c9b2b8..2531cf3 100644
--- a/tests/unit/Formatters/DotFormatterTest.php
+++ b/tests/unit/Formatters/DotFormatterTest.php
@@ -19,7 +19,7 @@ public function testFormatsSimpleDependencies(): void
.'}'
;
- assertEquals($expected, (new DotFormatter())->format(DependencyHelper::map('
+ $this->assertEquals($expected, (new DotFormatter())->format(DependencyHelper::map('
A --> B
C --> D
A\\b --> D\\c
diff --git a/tests/unit/Formatters/PlantUmlFormatterTest.php b/tests/unit/Formatters/PlantUmlFormatterTest.php
index 7d155e7..9f95c9e 100644
--- a/tests/unit/Formatters/PlantUmlFormatterTest.php
+++ b/tests/unit/Formatters/PlantUmlFormatterTest.php
@@ -23,7 +23,7 @@ protected function setUp(): void
public function testFormat(): void
{
$dependencyCollection = DependencyHelper::map('ClassA --> ClassB, ClassC');
- assertEquals("@startuml\n\n"
+ $this->assertEquals("@startuml\n\n"
."ClassA --|> ClassB\n"
."ClassA --|> ClassC\n"
.'@enduml', $this->plantUmlFormatter->format($dependencyCollection));
@@ -31,7 +31,7 @@ public function testFormat(): void
public function testFormatsNestedNamespaces(): void
{
- assertEquals('@startuml
+ $this->assertEquals('@startuml
namespace A {
namespace b {
}
diff --git a/tests/unit/OS/DotWrapperTest.php b/tests/unit/OS/DotWrapperTest.php
index 9844f07..fac2b7b 100644
--- a/tests/unit/OS/DotWrapperTest.php
+++ b/tests/unit/OS/DotWrapperTest.php
@@ -45,12 +45,17 @@ public function testRunsDot(): void
$root = vfsStream::setup()->url();
$this->shellWrapper
- ->expects(exactly(2))
+ ->expects($this->exactly(2))
->method('run')
- ->withConsecutive(
- ['dot -V'],
- ['dot -O -Tpng '.$root.'/test']
- )
+ ->willReturnCallback(function ($command) use ($root) {
+ if ($command === 'dot -V') {
+ return 0;
+ }
+ if ($command === 'dot -O -Tpng '.$root.'/test') {
+ return 0;
+ }
+ return 1;
+ })
;
$this->dotWrapper->generate(new DependencyMap(), new SplFileInfo($root.'/test.png'), true);
}
@@ -59,9 +64,9 @@ public function testKeepsDotFiles(): void
{
$root = vfsStream::setup()->url();
$testFile = new SplFileInfo($root.'/test');
- assertFileNotExists($testFile->getPathname());
+ $this->assertFileDoesNotExist($testFile->getPathname());
$this->dotWrapper->generate(new DependencyMap(), new SplFileInfo($testFile->getPathname()), true);
- assertFileExists($testFile->getPathname());
+ $this->assertFileExists($testFile->getPathname());
}
@@ -70,6 +75,6 @@ public function testRemovesDotFiles(): void
$root = vfsStream::setup()->url();
$testFile = new SplFileInfo($root.'/test');
$this->dotWrapper->generate(new DependencyMap(), new SplFileInfo($root.'/test.png'), false);
- assertFileNotExists($testFile->getPathname());
+ $this->assertFileDoesNotExist($testFile->getPathname());
}
}
diff --git a/tests/unit/OS/PhpFileFinderTest.php b/tests/unit/OS/PhpFileFinderTest.php
index 32174ea..e77423a 100644
--- a/tests/unit/OS/PhpFileFinderTest.php
+++ b/tests/unit/OS/PhpFileFinderTest.php
@@ -31,7 +31,7 @@ public function testFindsSingleFileInFlatStructure(): void
$dir = new SplFileInfo($mockDir->url());
$expected = (new PhpFileSet())
->add(new PhpFile(new SplFileInfo($mockDir->url().'/root/someFile.php')));
- assertEquals($expected, $this->finder->find($dir));
+ $this->assertEquals($expected, $this->finder->find($dir));
}
public function testFindsFilesInDeepStructure(): void
@@ -58,7 +58,7 @@ public function testFindsFilesInDeepStructure(): void
->add(new PhpFile(new SplFileInfo($mockDir->url().'/root/dirA/dirB/fileInB.php')))
->add(new PhpFile(new SplFileInfo($mockDir->url().'/root/dirA/dirB/fileInB2.php')))
->add(new PhpFile(new SplFileInfo($mockDir->url().'/root/dirA/dirB/dirC/fileInC.php')));
- assertEquals($expected, $this->finder->find($dir));
+ $this->assertEquals($expected, $this->finder->find($dir));
}
public function testFindsNothingIfThereIsNothing(): void
@@ -79,7 +79,7 @@ public function testFindsNothingIfThereIsNothing(): void
],
]);
$dir = new SplFileInfo($mockDir->url());
- assertEmpty($this->finder->find($dir));
+ $this->assertEmpty($this->finder->find($dir));
}
public function testFindFilesInDeeplyNestedDirectory(): void
@@ -108,6 +108,6 @@ public function testFindFilesInDeeplyNestedDirectory(): void
$mockDir->url().'/root/dirA',
$mockDir->url().'/root/dirB',
]);
- assertEquals($expected, $actual);
+ $this->assertEquals($expected, $actual);
}
}
diff --git a/tests/unit/OS/PhpFileSetTest.php b/tests/unit/OS/PhpFileSetTest.php
index 78bff0a..b269cdd 100644
--- a/tests/unit/OS/PhpFileSetTest.php
+++ b/tests/unit/OS/PhpFileSetTest.php
@@ -20,7 +20,7 @@ public function testEquals(): void
->add($file);
$collection2 = (new PhpFileSet())
->add($file);
- assertTrue($collection1->equals($collection2));
+ $this->assertTrue($collection1->equals($collection2));
}
public function testDoesNotAllowDuplicated(): void
@@ -28,7 +28,7 @@ public function testDoesNotAllowDuplicated(): void
$set = (new PhpFileSet())
->add(new PhpFile(new SplFileInfo(__DIR__)))
->add(new PhpFile(new SplFileInfo(__DIR__)));
- assertCount(1, $set);
+ $this->assertCount(1, $set);
}
public function testIsImmutable(): void
@@ -36,7 +36,7 @@ public function testIsImmutable(): void
$set = (new PhpFileSet())
->add(new PhpFile(new SplFileInfo(__DIR__)));
$setAfterRefusingDuplicate = $set->add(new PhpFile(new SplFileInfo(__DIR__)));
- assertNotSame($set, $setAfterRefusingDuplicate);
+ $this->assertNotSame($set, $setAfterRefusingDuplicate);
}
public function testNotEquals(): void
@@ -45,18 +45,18 @@ public function testNotEquals(): void
->add(new PhpFile(new SplFileInfo(sys_get_temp_dir())));
$collection2 = (new PhpFileSet())
->add(new PhpFile(new SplFileInfo(__DIR__)));
- assertFalse($collection1->equals($collection2));
+ $this->assertFalse($collection1->equals($collection2));
}
public function testCount0WhenEmpty(): void
{
$collection1 = new PhpFileSet();
- assertCount(0, $collection1);
+ $this->assertCount(0, $collection1);
}
public function testCount(): void
{
- assertCount(2, (new PhpFileSet())
+ $this->assertCount(2, (new PhpFileSet())
->add(new PhpFile(new SplFileInfo(__DIR__)))
->add(new PhpFile(new SplFileInfo(__DIR__.'/../../../composer.json'))));
}
@@ -65,7 +65,7 @@ public function testEach(): void
{
$collection1 = (new PhpFileSet())->add(new PhpFile(new SplFileInfo(__DIR__)));
$collection1->each(function (PhpFile $file) {
- assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $file);
+ $this->assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $file);
});
}
@@ -75,8 +75,8 @@ public function testMapToArray(): void
->add(new PhpFile(new SplFileInfo(__DIR__)))
->add(new PhpFile(new SplFileInfo(__FILE__)))
->toArray();
- assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $collection1[0]);
- assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $collection1[1]);
+ $this->assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $collection1[0]);
+ $this->assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $collection1[1]);
}
public function testAddAll(): void
@@ -86,8 +86,8 @@ public function testAddAll(): void
->add(new PhpFile(new SplFileInfo(__DIR__)))
->add(new PhpFile(new SplFileInfo(__FILE__)));
$combinedCollection = $collection1->addAll($collection2)->toArray();
- assertCount(2, $combinedCollection);
- assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $combinedCollection[0]);
- assertEquals(new PhpFile(new SplFileInfo(__FILE__)), $combinedCollection[1]);
+ $this->assertCount(2, $combinedCollection);
+ $this->assertEquals(new PhpFile(new SplFileInfo(__DIR__)), $combinedCollection[0]);
+ $this->assertEquals(new PhpFile(new SplFileInfo(__FILE__)), $combinedCollection[1]);
}
}
diff --git a/tests/unit/OS/PhpFileTest.php b/tests/unit/OS/PhpFileTest.php
index 3d1e069..fb6a379 100644
--- a/tests/unit/OS/PhpFileTest.php
+++ b/tests/unit/OS/PhpFileTest.php
@@ -22,14 +22,14 @@ public function testEquals(): void
{
$file1 = new PhpFile(new SplFileInfo(sys_get_temp_dir()));
$file2 = new PhpFile(new SplFileInfo(sys_get_temp_dir()));
- assertTrue($file1->equals($file2));
+ $this->assertTrue($file1->equals($file2));
}
public function testNotEquals(): void
{
$file1 = new PhpFile(new SplFileInfo(sys_get_temp_dir()));
$file2 = new PhpFile(new SplFileInfo(__DIR__));
- assertFalse($file1->equals($file2));
+ $this->assertFalse($file1->equals($file2));
}
public function testReturnsCode(): void
@@ -39,7 +39,7 @@ public function testReturnsCode(): void
'someFile.php' => $code,
]);
$file = new PhpFile(new SplFileInfo($mockDir->url().'/someFile.php'));
- assertEquals($code, $file->code());
+ $this->assertEquals($code, $file->code());
}
public function testToString(): void
diff --git a/tests/unit/OS/PlantUmlWrapperTest.php b/tests/unit/OS/PlantUmlWrapperTest.php
index b32db55..b98e61b 100644
--- a/tests/unit/OS/PlantUmlWrapperTest.php
+++ b/tests/unit/OS/PlantUmlWrapperTest.php
@@ -41,14 +41,14 @@ public function testDetectsIfPlantUmlIsNotInstalled(): void
public function testDetectsIfPlantUmlIsInstalled(): void
{
$this->shellWrapper->method('run')->willReturn(0);
- assertInstanceOf(PlantUmlWrapper::class, new PlantUmlWrapper($this->plantUmlFormatter, $this->shellWrapper));
+ $this->assertInstanceOf(PlantUmlWrapper::class, new PlantUmlWrapper($this->plantUmlFormatter, $this->shellWrapper));
}
public function testGenerate(): void
{
$plantUml = new PlantUmlWrapper($this->plantUmlFormatter, $this->shellWrapper);
$plantUml->generate(new DependencyMap(), new SplFileInfo(sys_get_temp_dir().'/dependencies.png'), true);
- assertFileExists(sys_get_temp_dir().'/dependencies.uml');
+ $this->assertFileExists(sys_get_temp_dir().'/dependencies.uml');
unlink(sys_get_temp_dir().'/dependencies.uml');
}
@@ -56,6 +56,6 @@ public function testRemoveUml(): void
{
$plantUml = new PlantUmlWrapper($this->plantUmlFormatter, $this->shellWrapper);
$plantUml->generate(new DependencyMap(), new SplFileInfo(sys_get_temp_dir().'/dependencies.png'));
- assertFileNotExists(sys_get_temp_dir().'/dependencies.uml');
+ $this->assertFileDoesNotExist(sys_get_temp_dir().'/dependencies.uml');
}
}
diff --git a/tests/unit/OS/ShellWrapperTest.php b/tests/unit/OS/ShellWrapperTest.php
index e8f05d6..7a5bab4 100644
--- a/tests/unit/OS/ShellWrapperTest.php
+++ b/tests/unit/OS/ShellWrapperTest.php
@@ -16,11 +16,11 @@ class ShellWrapperTest extends TestCase
*/
public function testDetectsEcho(): void
{
- assertEquals(0, (new ShellWrapper())->run('echo'));
+ $this->assertEquals(0, (new ShellWrapper())->run('echo'));
}
public function testDetectsWhenApplicationNotInstalled(): void
{
- assertNotEquals(0, (new ShellWrapper())->run('xjcsajhckjsdfhksdf'));
+ $this->assertNotEquals(0, (new ShellWrapper())->run('xjcsajhckjsdfhksdf'));
}
}
diff --git a/tests/unit/Util/DependencyContainerTest.php b/tests/unit/Util/DependencyContainerTest.php
index ae23367..2bb1124 100644
--- a/tests/unit/Util/DependencyContainerTest.php
+++ b/tests/unit/Util/DependencyContainerTest.php
@@ -37,6 +37,6 @@ public function provideMethods(): array
*/
public function testCanInstantiateAllDependencies(string $methodName, string $expectedReturnType): void
{
- assertInstanceOf($expectedReturnType, (new DependencyContainer([]))->{$methodName}());
+ $this->assertInstanceOf($expectedReturnType, (new DependencyContainer([]))->{$methodName}());
}
}
diff --git a/tests/unit/Util/FunctionalTest.php b/tests/unit/Util/FunctionalTest.php
index 66d330e..56d8d56 100644
--- a/tests/unit/Util/FunctionalTest.php
+++ b/tests/unit/Util/FunctionalTest.php
@@ -19,7 +19,7 @@ public function testCompose(): void
$multiplyByTwo = function ($x) {
return $x * 2;
};
- assertEquals(8, Functional::compose(
+ $this->assertEquals(8, Functional::compose(
$incrementByOne,
$multiplyByTwo,
$multiplyByTwo
@@ -28,6 +28,6 @@ public function testCompose(): void
public function testComposeWithoutArgumentsReturnsId(): void
{
- assertEquals(9, Functional::compose()(9));
+ $this->assertEquals(9, Functional::compose()(9));
}
}
diff --git a/tests/unit/Util/UtilTest.php b/tests/unit/Util/UtilTest.php
index 4f04b7d..750c943 100644
--- a/tests/unit/Util/UtilTest.php
+++ b/tests/unit/Util/UtilTest.php
@@ -13,28 +13,28 @@ class UtilTest extends TestCase
{
public function testArrayMatchesAtLeastOnce(): void
{
- assertTrue(Util::array_once([1, 2, 3, 'tt'], function ($value, $index) {
+ $this->assertTrue(Util::array_once([1, 2, 3, 'tt'], function ($value, $index) {
return $value === 'tt';
}));
}
public function testArrayMatchesIndex(): void
{
- assertTrue(Util::array_once([1, 2, 3, 'tt'], function ($value, $index) {
+ $this->assertTrue(Util::array_once([1, 2, 3, 'tt'], function ($value, $index) {
return $index === 3 && $value === 'tt';
}));
}
public function testArrayMatchesNothing(): void
{
- assertFalse(Util::array_once([1, 2, 3, 'tt'], function ($value, $index) {
+ $this->assertFalse(Util::array_once([1, 2, 3, 'tt'], function ($value, $index) {
return $value === 'xxx';
}));
}
public function testReduceArrayWithKeys(): void
{
- assertEquals('0a1b2c3d', Util::reduce(['a', 'b', 'c', 'd'], function (string $carry, int $index, string $value) {
+ $this->assertEquals('0a1b2c3d', Util::reduce(['a', 'b', 'c', 'd'], function (string $carry, int $index, string $value) {
return $carry.$index.$value;
}, ''));
}
|