Codeception / Codeception/AspectMock

Non-existent functions can't be mocked since 2.1.0

Ouverte
#158 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
PHP
Étoiles
784
Forks
132
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

The problem was introduced here:
https://github.com/Codeception/AspectMock/pull/133/files#diff-50b2697c4aa86740dcae323b3d7ebe44R44

The `placeOptionalAndReferenceFunction` method uses `ReflectionFunction` which throws an exception if a non-existent function name is passed:

> [ReflectionException] Function somefunc() does not exist

Before that change it worked fine when trying to mock a non-existent function. This is a valid use case for a plugin architecture where you may not have desired functions in a test environment.

Can it be like this, for example:
```php
if (function_exists($function)) {
$this->placeOptionalAndReferenceFunction($namespace, $function);
}
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start with the placeOptionalAndReferenceFunction method and the referenced pull request diff, focusing on its ReflectionFunction call. Confirm the behavior for a non-existent function, then verify that mocking such a function no longer raises a ReflectionException.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
php
Domaine
testing
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.