Skip to content

Commit

Permalink
Merge pull request #544 from magento-performance/ACPT-1359
Browse files Browse the repository at this point in the history
ACPT-1359: Fix testObserverHasNoExtraPublicMethods test on PR
  • Loading branch information
andimov authored Jun 2, 2023
2 parents 267bcac + b12ed72 commit 4d6f13b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ public function testObserverHasNoExtraPublicMethods()
$errors = [];
foreach (self::$observerClasses as $observerClass) {
$reflection = (new \ReflectionClass($observerClass));
$publicMethodsCount = 0;
$maxCountMethod = $reflection->getConstructor() ? 2 : 1;
$publicMethods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($publicMethods as $publicMethod) {
if (!str_starts_with($publicMethod->getName(), '_')) {
$publicMethodsCount++;
}
}

if (count($reflection->getMethods(\ReflectionMethod::IS_PUBLIC)) > $maxCountMethod) {
if ($publicMethodsCount > $maxCountMethod) {
$errors[] = $observerClass;
}
}
$errors = array_diff($errors, [GetPriceConfigurationObserver::class]);

if ($errors) {
$errors = array_unique($errors);
Expand Down

0 comments on commit 4d6f13b

Please sign in to comment.