public function testGetProxyValue()
 {
     $name = 'entity';
     $existingEntity = $this->getMock('Doctrine\\Common\\Persistence\\Proxy');
     $existingEntity->expects($this->once())->method('__isInitialized')->will($this->returnValue(false));
     $existingEntity->expects($this->once())->method('__load');
     $this->data->set($name, $existingEntity);
     $this->assertEquals($existingEntity, $this->data->get($name));
     $removedEntity = $this->getMock('Doctrine\\Common\\Persistence\\Proxy');
     $removedEntity->expects($this->once())->method('__isInitialized')->will($this->returnValue(false));
     $removedEntity->expects($this->once())->method('__load')->will($this->throwException(new EntityNotFoundException()));
     $this->data->set($name, $removedEntity);
     $this->assertNull($this->data->get($name));
 }
Esempio n. 2
0
 public function testMappedField()
 {
     $data = new \stdClass();
     $data->value = 'one';
     $this->data->setFieldsMapping(array('test2' => 'test.value'));
     $this->assertFalse($this->data->has('test'), 'no test');
     $this->assertFalse($this->data->has('test2'), 'no test2');
     $this->data->set('test', $data);
     $this->assertSame($data, $this->data->get('test'));
     $this->assertEquals('one', $this->data->get('test2'));
     $this->assertTrue($this->data->has('test'), 'has test');
     $this->assertTrue($this->data->has('test2'), 'has test2');
     $this->data->set('test2', 'two');
     $this->assertEquals('two', $this->data->get('test2'));
     $actualTest = $this->data->get('test');
     $this->assertEquals('two', $actualTest->value);
     $propertyPath = new PropertyPath('[test].value');
     $this->assertEquals('two', $this->data->get($propertyPath));
 }
 public function testDenormalize()
 {
     $attributeName = 'test_attribute';
     $data = array($attributeName => 'normalized_value');
     $expectedData = new WorkflowData(array($attributeName => 'denormalized_value'));
     $this->normalizer->addAttributeNormalizer($this->attributeNormalizer);
     $this->normalizer->setSerializer($this->serializer);
     $this->serializer->expects($this->once())->method('getWorkflow')->will($this->returnValue($this->workflow));
     $this->attributeManager->expects($this->once())->method('getAttribute')->with($attributeName)->will($this->returnValue($this->attribute));
     $this->attributeNormalizer->expects($this->once())->method('supportsDenormalization')->with($this->workflow, $this->attribute, $data[$attributeName])->will($this->returnValue(true));
     $this->attributeNormalizer->expects($this->once())->method('denormalize')->with($this->workflow, $this->attribute, $data[$attributeName])->will($this->returnValue($expectedData->get($attributeName)));
     $this->assertEquals($expectedData, $this->normalizer->denormalize($data, 'Oro\\Bundle\\WorkflowBundle\\Model\\WorkflowData'));
 }