/** * @test */ public function getItemWaitsWhenItemIsUnderConstruction() { $storage = $this->mockWithPhpUnit(); $storage->expects($this->at(0))->method('hasItem')->with($this->delayedKey)->will($this->returnValue(true)); $storage->expects($this->at(1))->method('hasItem')->with($this->delayedKey)->will($this->returnValue(false)); $arg1 = 'foo'; $arg2 = 'bar'; $arg3 = 'baz'; $storage->expects($this->once())->method('getItem')->with($arg1, $arg2, $arg3)->will($this->returnValue(['foo'])); $return = $this->cache->getItem($arg1, $arg2, $arg3); $this->assertEquals(['foo'], $return); }