public function testCache() { $this->doSetup(2); $result = $this->getMockBuilder('Silktide\\SemRushApi\\Model\\Result')->disableOriginalConstructor()->getMock(); $cache = $this->getMock('Silktide\\SemRushApi\\Cache\\CacheInterface'); $cache->expects($this->exactly(2))->method('cache'); $cache->expects($this->exactly(2))->method('fetch')->willReturnOnConsecutiveCalls(null, $result); $this->resultFactory->expects($this->exactly(1))->method('create')->willReturn($result); $this->instance->setCache($cache); $resultOne = $this->instance->getDomainAdwordsUnique('domain.com', []); $resultTwo = $this->instance->getDomainAdwordsUnique('domain.com', []); $this->assertEquals($resultOne, $resultTwo); }