Skip to content

Commit

Permalink
added a test for not extend rule when a class extends another class
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessandroMinoccheri committed Feb 14, 2023
1 parent 6e1386d commit d019bde
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Unit/Expressions/ForClasses/NotExtendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,26 @@ public function test_it_should_return_violation_error(): void
self::assertEquals(1, $violations->count());
self::assertEquals('should not extend My\BaseClass because we want to add this rule for our software', $violationError);
}

public function test_it_should_not_return_violation_error_if_extends_another_class(): void
{
$notExtend = new NotExtend('My\BaseClass');

$classDescription = new ClassDescription(
FullyQualifiedClassName::fromString('HappyIsland'),
[],
[],
FullyQualifiedClassName::fromString('My\AnotherClass'),
false,
false,
false
);
$because = 'we want to add this rule for our software';
$violationError = $notExtend->describe($classDescription, $because)->toString();

$violations = new Violations();
$notExtend->evaluate($classDescription, $violations, $because);

self::assertEquals(0, $violations->count());
}
}

0 comments on commit d019bde

Please sign in to comment.