-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add more test cases to improve mutation coverage
- Loading branch information
1 parent
dbc286b
commit e402155
Showing
14 changed files
with
386 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,6 @@ | |
"mutators": { | ||
"@default": true | ||
}, | ||
"minMsi": 87, | ||
"minCoveredMsi": 87 | ||
"minMsi": 85, | ||
"minCoveredMsi": 85 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
class plStyleName | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,274 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* PHP version 7.4 | ||
* | ||
* This source file is subject to the license that is bundled with this package in the file LICENSE. | ||
*/ | ||
|
||
namespace PhUml\Configuration; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PhUml\Code\ClassDefinition; | ||
use PhUml\Code\Name; | ||
use PhUml\Parser\CodebaseDirectory; | ||
|
||
final class DigraphBuilderTest extends TestCase | ||
{ | ||
/** @test */ | ||
function it_builds_a_code_finder_that_searches_recursively() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => true, | ||
'associations' => 'true', | ||
'hide-private' => true, | ||
'hide-protected' => 0, | ||
'hide-attributes' => 1, | ||
'hide-methods' => 'true', | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/interfaces/processor'); | ||
|
||
$codeFinder = $builder->codeFinder($directory); | ||
|
||
$this->assertCount(2, $codeFinder->files()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_code_finder_that_does_not_search_recursively() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => false, | ||
'associations' => 'true', | ||
'hide-private' => true, | ||
'hide-protected' => 0, | ||
'hide-attributes' => 1, | ||
'hide-methods' => 'true', | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/interfaces/processor'); | ||
|
||
$codeFinder = $builder->codeFinder($directory); | ||
|
||
$this->assertCount(1, $codeFinder->files()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_excludes_attributes() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => 'true', | ||
'hide-private' => true, | ||
'hide-protected' => 0, | ||
'hide-attributes' => true, | ||
'hide-methods' => 'true', | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/interfaces/processor/graphviz'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(1, $codebase->definitions()); | ||
$className = new Name('plGraphvizProcessorStyle'); | ||
$this->assertTrue($codebase->has($className)); | ||
$this->assertFalse($codebase->get($className)->hasAttributes()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_includes_attributes() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => 'true', | ||
'hide-private' => 0, | ||
'hide-protected' => 0, | ||
'hide-attributes' => false, | ||
'hide-methods' => 'true', | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/interfaces/processor/graphviz'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(1, $codebase->definitions()); | ||
$className = new Name('plGraphvizProcessorStyle'); | ||
$this->assertTrue($codebase->has($className)); | ||
$this->assertTrue($codebase->get($className)->hasAttributes()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_excludes_methods() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => 'true', | ||
'hide-private' => [], | ||
'hide-protected' => 0, | ||
'hide-attributes' => false, | ||
'hide-methods' => 'true', | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/interfaces/processor/graphviz'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(1, $codebase->definitions()); | ||
$className = new Name('plGraphvizProcessorStyle'); | ||
$this->assertTrue($codebase->has($className)); | ||
$this->assertEmpty($codebase->get($className)->methods()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_includes_methods() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => 'true', | ||
'hide-private' => [], | ||
'hide-protected' => 0, | ||
'hide-attributes' => null, | ||
'hide-methods' => false, | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/interfaces/processor/graphviz'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(1, $codebase->definitions()); | ||
$className = new Name('plGraphvizProcessorStyle'); | ||
$this->assertTrue($codebase->has($className)); | ||
$this->assertCount(1, $codebase->get($className)->methods()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_excludes_protected_members() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => 'true', | ||
'hide-private' => [], | ||
'hide-protected' => true, | ||
'hide-attributes' => false, | ||
'hide-methods' => 'true', | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/exceptions/base'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(2, $codebase->definitions()); | ||
$className = new Name('plBasePropertyException'); | ||
$this->assertTrue($codebase->has($className)); | ||
/** @var ClassDefinition $definition */ | ||
$definition = $codebase->get($className); | ||
$this->assertCount(3, $definition->constants()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_includes_protected_members() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => 'true', | ||
'hide-private' => [], | ||
'hide-protected' => false, | ||
'hide-attributes' => null, | ||
'hide-methods' => 'true', | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/exceptions/base'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(2, $codebase->definitions()); | ||
$className = new Name('plBasePropertyException'); | ||
$this->assertTrue($codebase->has($className)); | ||
/** @var ClassDefinition $definition */ | ||
$definition = $codebase->get($className); | ||
$this->assertCount(4, $definition->constants()); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_includes_relationships_from_attributes_and_constructor_parameters() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => true, | ||
'hide-private' => 0, | ||
'hide-protected' => null, | ||
'hide-attributes' => [], | ||
'hide-methods' => false, | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/classes/processor/graphviz/style'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(3, $codebase->definitions()); | ||
$this->assertTrue($codebase->has(new Name('plStyleName'))); | ||
} | ||
|
||
/** @test */ | ||
function it_builds_a_parser_that_excludes_relationships_from_attributes_and_constructor_parameters() | ||
{ | ||
$configuration = new DigraphConfiguration([ | ||
'recursive' => 0, | ||
'associations' => false, | ||
'hide-private' => 0, | ||
'hide-protected' => null, | ||
'hide-attributes' => [], | ||
'hide-methods' => false, | ||
'hide-empty-blocks' => '', | ||
'theme' => 'phuml', | ||
]); | ||
$builder = new DigraphBuilder($configuration); | ||
$directory = new CodebaseDirectory(__DIR__ . '/../../resources/.code/classes/processor/graphviz/style'); | ||
$finder = $builder->codeFinder($directory); | ||
|
||
$parser = $builder->codeParser(); | ||
|
||
$codebase = $parser->parse($finder); | ||
|
||
$this->assertCount(2, $codebase->definitions()); | ||
$this->assertFalse($codebase->has(new Name('plStyleName'))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.