Skip to content

Commit

Permalink
Add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 1, 2020
1 parent cb0469f commit 5ca5a3a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 18 deletions.
18 changes: 18 additions & 0 deletions tests/_fixture/FixtureAnotherTrait.php
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);
/*
* This file is part of sebastian/code-unit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeUnit\Fixture;

trait FixtureAnotherTrait
{
public function anotherMethod(): void
{
// ...
}
}
Expand Up @@ -9,19 +9,11 @@
*/
namespace SebastianBergmann\CodeUnit\Fixture;

class FixtureParentClass
final class FixtureChildClassWithTrait extends FixtureParentClassWithTrait
{
public function publicMethod(): void
{
// ...
}
use FixtureAnotherTrait;

protected function protectedMethod(): void
{
// ...
}

private function privateMethod(): void
public function publicMethod(): void
{
// ...
}
Expand Down
2 changes: 1 addition & 1 deletion tests/_fixture/FixtureClass.php
Expand Up @@ -9,7 +9,7 @@
*/
namespace SebastianBergmann\CodeUnit\Fixture;

class FixtureClass extends FixtureParentClass
class FixtureClass
{
public function publicMethod(): void
{
Expand Down
20 changes: 20 additions & 0 deletions tests/_fixture/FixtureParentClassWithTrait.php
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);
/*
* This file is part of sebastian/code-unit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeUnit\Fixture;

class FixtureParentClassWithTrait
{
use FixtureTrait;

public function publicMethod(): void
{
// ...
}
}
16 changes: 10 additions & 6 deletions tests/unit/MapperTest.php
Expand Up @@ -10,10 +10,12 @@
namespace SebastianBergmann\CodeUnit;

use PHPUnit\Framework\TestCase;
use SebastianBergmann\CodeUnit\Fixture\FixtureAnotherTrait;
use SebastianBergmann\CodeUnit\Fixture\FixtureChildClassWithTrait;
use SebastianBergmann\CodeUnit\Fixture\FixtureClass;
use SebastianBergmann\CodeUnit\Fixture\FixtureClassWithTrait;
use SebastianBergmann\CodeUnit\Fixture\FixtureInterface;
use SebastianBergmann\CodeUnit\Fixture\FixtureParentClass;
use SebastianBergmann\CodeUnit\Fixture\FixtureParentClassWithTrait;
use SebastianBergmann\CodeUnit\Fixture\FixtureTrait;

/**
Expand Down Expand Up @@ -59,7 +61,7 @@ public function testCanMapStringWithClassNameToCodeUnitObjects(): void
/**
* @testdox Can map 'ClassName' string to code unit objects
*/
public function testCanBeCreatedForClassesAndTheTraitsTheyUseToCodeUnitObjects(): void
public function testMapClassesAndTheTraitsTheyUseToCodeUnitObjects(): void
{
$units = (new Mapper)->stringToCodeUnits(FixtureClassWithTrait::class);

Expand All @@ -73,11 +75,13 @@ public function testCanBeCreatedForClassesAndTheTraitsTheyUseToCodeUnitObjects()
*/
public function testCanMapStringWithClassNameAndSelectorForParentClassesToCodeUnitObjects(): void
{
$units = (new Mapper)->stringToCodeUnits(FixtureClass::class . '<extended>');
$units = (new Mapper)->stringToCodeUnits(FixtureChildClassWithTrait::class . '<extended>');

$this->assertCount(2, $units);
$this->assertSame(FixtureClass::class, $units->asArray()[0]->name());
$this->assertSame(FixtureParentClass::class, $units->asArray()[1]->name());
$this->assertCount(4, $units);
$this->assertSame(FixtureChildClassWithTrait::class, $units->asArray()[0]->name());
$this->assertSame(FixtureAnotherTrait::class, $units->asArray()[1]->name());
$this->assertSame(FixtureParentClassWithTrait::class, $units->asArray()[2]->name());
$this->assertSame(FixtureTrait::class, $units->asArray()[3]->name());
}

/**
Expand Down

0 comments on commit 5ca5a3a

Please sign in to comment.