Answer the question
In order to leave comments, you need to log in
How do unit tests work?
How do unit tests work? (particularly php) If I cause an error in the code, the tests do not show this.
Example:
Test:
public function testFindAll(): void
{
self::bootKernel();
$repository = static::$kernel->getContainer()->get(PropertyInMemoryRepository::class);
$this->assertInstanceOf(PropertyCollection::class, $repository->findAll(1, 1, 1));
$count = $repository->findAll(1, 1, 1)->count();
$this->assertSame(3, $count);
}
public function findAll(int $groupId, int $page, int $limit, array $filters = []): PropertyCollection
{
$propertyCollection = new PropertyCollection();
foreach ($this->propertyCollection as $property) {
if ($property->getGroupIdValue() === $groupId) {
$propertyCollection->append($property);
}
}
return $propertyCollection;
}
$dProperties = $this->propertyRepository->findAll($this->getUser()->getGroupId(), 'string', $limit, $filters);
Answer the question
In order to leave comments, you need to log in
The error is that you are passing a string as the second argument in the controller?
If yes, then it will catch the controller test , not the findAll method, that test will not know by any magic that you will be passing invalid arguments somewhere else.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question