mock(TimeService::class); $favoritesDao = new FavoritesDao( $this->databaseConnection, $userDao, $postDao, $timeServiceMock); $user = self::getTestUser('olivia'); $userDao->save($user); $post = self::getTestPost(); $postDao->save($post); $favorite = new Favorite(); $favorite->setUserId($user->getId()); $favorite->setPostId($post->getId()); $favorite->setTime(date('c')); $favoritesDao->save($favorite); $savedFavorite = $favoritesDao->findById($favorite->getId()); $this->assertNotNull($savedFavorite->getUserId()); $this->assertNotNull($savedFavorite->getPostId()); $this->assertEquals($favorite->getTime(), $savedFavorite->getTime()); $this->assertEntitiesEqual($user, $savedFavorite->getUser()); $this->assertEntitiesEqual($post, $savedFavorite->getPost()); } }