Last active
August 3, 2021 09:18
-
-
Save mlebkowski/4b90b97f8788cddf7f527c34dc2f1804 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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