public function testDelete()
 {
     $application = \Stormpath\Resource\Application::instantiate(array('name' => makeUniqueName('AccountStoreMappingTest Test Delete')));
     self::createResource(\Stormpath\Resource\Application::PATH, $application);
     $accountStoreMappingWithDir = \Stormpath\Resource\AccountStoreMapping::create(array('accountStore' => self::$directory, 'application' => $application));
     $href = $accountStoreMappingWithDir->href;
     $accountStoreMapping = \Stormpath\Resource\AccountStoreMapping::get($href);
     $this->assertInstanceOf('Stormpath\\Resource\\AccountStoreMapping', $accountStoreMapping);
     $this->assertInstanceOf('Stormpath\\Resource\\Directory', $accountStoreMapping->accountStore);
     $accountStoreMapping->delete();
     try {
         \Stormpath\Resource\AccountStoreMapping::get($href);
         $application->delete();
         $this->fail('Should have thrown a ResourceError.');
     } catch (\Stormpath\Resource\ResourceError $re) {
         $this->assertTrue(true);
     }
     $application->delete();
 }
 private function warmResources()
 {
     if (config('stormpath.application.href') == null) {
         return;
     }
     $cache = $this->app['cache.store'];
     if ($cache->has('stormpath.resourcesWarm') && $cache->get('stormpath.resourcesWarm') == true) {
         return;
     }
     app('stormpath.client');
     $application = app('stormpath.application');
     $dasm = AccountStoreMapping::get($application->defaultAccountStoreMapping->href);
     $mappings = $application->getAccountStoreMappings(['expand' => 'accountStore']);
     $accountStoreArray = [];
     foreach ($mappings as $mapping) {
         $accountStoreArrayValues = ['href' => $mapping->accountStore->href, 'name' => $mapping->accountStore->name];
         if (isset($mapping->accountStore->provider)) {
             $accountStoreArrayValues['provider'] = ['href' => $mapping->accountStore->provider->href, 'providerId' => $mapping->accountStore->provider->providerId];
         }
         $accountStoreArray[] = $accountStoreArrayValues;
     }
     $asm = AccountStoreMapping::get($application->accountStoreMappings->href, ['expand' => 'accountStore']);
     $passwordPolicy = $dasm->getAccountStore()->getProperty('passwordPolicy');
     $accountCreationPolicy = $dasm->getAccountStore(['expand' => 'accountCreationPolicy'])->accountCreationPolicy;
     $passwordPolicies = PasswordPolicies::get($passwordPolicy->href);
     $cache->rememberForever('stormpath.defaultAccountStoreMapping', function () use($dasm) {
         return $dasm;
     });
     $cache->rememberForever('stormpath.accountStoreMappings', function () use($asm) {
         return $asm;
     });
     $cache->rememberForever('stormpath.accountStores', function () use($accountStoreArray) {
         return $accountStoreArray;
     });
     $cache->rememberForever('stormpath.passwordPolicy', function () use($passwordPolicy) {
         return $passwordPolicy;
     });
     $cache->rememberForever('stormpath.accountCreationPolicy', function () use($accountCreationPolicy) {
         return $accountCreationPolicy;
     });
     $cache->rememberForever('stormpath.passwordPolicies', function () use($passwordPolicies) {
         return $passwordPolicies;
     });
     $cache->rememberForever('stormpath.resourcesWarm', function () {
         return true;
     });
 }