Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public function findUpcomingForPatient(Patient $patient): ?Visit
{
- return $this->cache->fetch($patient->getId())
- ?: $this->visits->findUpcomingForPatient($patient);
+ $key = $patient->getId();
+ if ($this->cache->contains($key)) {
+ return $this->cache->fetch($key);
+ }
+
+ return $this->visits->findUpcomingForPatient($patient);
}
<?php
public function repository call is prevented if the cache contains a null value()
{
// given …
// when:
$sut->prefetch($this->task);
// then:
$visits
->expects(self::never())
->method('findUpcomingForPatient');
$sut->findUpcomingForPatient($this->patient);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment