app->instance(IOpenIdTrustedSiteRepository::class, $repo_mock); $mock_user = Mockery::mock(User::class); $mock_user->shouldReceive('addTrustedSite'); $service = $this->app[OpenIdServiceCatalog::TrustedSitesService]; $res = $service->addTrustedSite($mock_user, $realm = 'https://www.test.com', IAuthService::AuthorizationResponse_AllowForever, $data = []); $this->assertTrue(!is_null($res)); } public function testAdd(){ $service = $this->app[OpenIdServiceCatalog::TrustedSitesService]; $user = EntityManager::getRepository(User::class)->findOneBy(['identifier' => 'sebastian.marcet']); $res = $service->addTrustedSite($user, $realm = 'https://www.test.com', IAuthService::AuthorizationResponse_AllowForever, $data = []); $this->assertTrue(!is_null($res)); } public function testGetTrustedSitesByRealm(){ $realm = 'https://*.test.com'; $service = $this->app[OpenIdServiceCatalog::TrustedSitesService]; $user = EntityManager::getRepository(User::class)->findOneBy(['identifier' => 'sebastian.marcet']); $res = $service->addTrustedSite($user, $realm, IAuthService::AuthorizationResponse_AllowForever, $data = array('email','profile','address')); $this->assertTrue(!is_null($res)); $sites = $service->getTrustedSites($user,'https://www.dev.test.com', $data = array('email','address')); $this->assertTrue(is_array($sites)); $this->assertTrue(count($sites)>0); } }