/** * @expectedException \Giftcards\Encryption\Profile\ProfileNotFoundException */ public function testGetWhereNotThere() { $profile1 = new Profile($this->getFaker()->word, $this->getFaker()->word); $profile1Name = $this->getFaker()->unique()->word; $profile2 = new Profile($this->getFaker()->word, $this->getFaker()->word); $profile2Name = $this->getFaker()->unique()->word; $profile3 = new Profile($this->getFaker()->word, $this->getFaker()->word); $profile3Name = $this->getFaker()->unique()->word; $this->registry->set($profile1Name, $profile1)->set($profile2Name, $profile2)->set($profile3Name, $profile3)->get($this->getFaker()->unique()->word); }
public function testConfigureOptionsResolver() { $this->builder->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('profile'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('profile' => array('Giftcards\\Encryption\\Profile\\Profile')))->andReturn(\Mockery::self())->getMock()); $this->builderWithProfileRegistry->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('profile'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('profile' => array('Giftcards\\Encryption\\Profile\\Profile', 'string')))->andReturn(\Mockery::self())->getMock()->shouldReceive('setNormalizers')->once()->with(new EqualsMatcher(array('profile' => function () { })))->andReturn(\Mockery::self())->getMock()); $resolver = new OptionsResolver(); $this->builderWithProfileRegistry->configureOptionsResolver($resolver); $profile = new Profile($this->getFaker()->unique()->word, $this->getFaker()->unique()->word); $profileName = $this->getFaker()->unique()->word; $this->profileRegistry->set($profileName, $profile); $options = $resolver->resolve(array('profile' => $profileName)); $this->assertSame($options, $resolver->resolve(array('profile' => $profile))); $this->assertSame($profile, $options['profile']); }
public function setUp() { $this->cipherRegistry = new CipherRegistry(); $this->keySource = \Mockery::mock('Giftcards\\Encryption\\Key\\SourceInterface'); $this->profileRegistry = new ProfileRegistry(); $this->serializerDeserializer = \Mockery::mock('Giftcards\\Encryption\\CipherText\\Serializer\\SerializerDeserializerInterface'); $this->key1Name = $this->getFaker()->unique()->word; $this->key2Name = $this->getFaker()->unique()->word; $this->cipher1Name = $this->getFaker()->unique()->word; $this->cipher2Name = $this->getFaker()->unique()->word; $this->profile1Name = $this->getFaker()->unique()->word; $this->profile2Name = $this->getFaker()->unique()->word; $this->cipherRegistry->add(\Mockery::mock('Giftcards\\Encryption\\Cipher\\CipherInterface')->shouldReceive('getName')->andReturn($this->cipher1Name)->getMock())->add(\Mockery::mock('Giftcards\\Encryption\\Cipher\\CipherInterface')->shouldReceive('getName')->andReturn($this->cipher2Name)->getMock()); $this->keySource->shouldReceive('get')->with($this->key1Name)->andReturn($this->getFaker()->unique()->word)->getMock()->shouldReceive('get')->with($this->key2Name)->andReturn($this->getFaker()->unique()->word)->getMock(); $this->profileRegistry->set($this->profile1Name, new Profile($this->cipher1Name, $this->key1Name))->set($this->profile2Name, new Profile($this->cipher2Name, $this->key2Name)); $this->encryptor = new Encryptor($this->cipherRegistry, $this->keySource, $this->profileRegistry, $this->serializerDeserializer, $this->defaultProfile = $this->profile2Name); }
public function testSet() { $profile1 = new Profile($this->getFaker()->unique()->word, $this->getFaker()->unique()->word); $profile1Name = $this->getFaker()->unique()->word; $profile2 = new Profile($this->getFaker()->unique()->word, $this->getFaker()->unique()->word); $profile2Name = $this->getFaker()->unique()->word; $registry = new ProfileRegistry(); $registry->set($profile1Name, $profile1)->set($profile2Name, $profile2); $this->profileRegistryBuilder->set($profile1Name, $profile1)->set($profile2Name, $profile2->getCipher(), $profile2->getKeyName()); $this->assertEquals($registry, $this->profileRegistryBuilder->build()); }