/** * @test */ public function it_delegates_to_another_user_service_when_a_user_is_not_cached_by_username() { // The API service only expects one call. $this->apiService->expects($this->once())->method('getUserByUsername')->with($this->user->nick)->willReturn($this->user); // Get the user before he is cached. $this->assertEquals($this->user, $this->cachedService->getUserByUsername($this->user->nick)); // Make sure the user is cached now. Not only by username but also by // id. $this->assertEquals($this->user, $this->cachedService->getUserByUsername($this->user->nick)); $this->assertEquals($this->user, $this->cachedService->getUser($this->user->id)); }