/** * @param string $key * @param callable|null $callback * @return string */ public function get($key, $callback = null) { $value = $this->connector->get($key); if (is_null($value)) { $callback = $this->getCallback($callback); $value = $callback($key); if (!is_null($value)) { $this->connector->set($key, $value); } } return $value; }
public function test_get_ObjectNotFoundAndCallbackReturnsNull_setNotCalled() { $obj = $this->getTestSubjectWithNotCachedObject(); $this->connector->expects($this->never())->method('set'); $obj->setDefaultCallback(function () { return null; }); $obj->get('a'); }