/** * @depends testConstructor */ public function testSettersGetters() { $unitUnderTest = new PropertyMetadata('testProperty'); $this->assertEquals(false, $unitUnderTest->isExpose()); $unitUnderTest->setExpose(true); $this->assertEquals(true, $unitUnderTest->isExpose()); $this->assertEquals(false, $unitUnderTest->isNullSkipped()); $unitUnderTest->setNullSkipped(true); $this->assertEquals(true, $unitUnderTest->isNullSkipped()); $unitUnderTest->setSerializedName('serialized'); $this->assertEquals('serialized', $unitUnderTest->getSerializedName()); $unitUnderTest->setType('string'); $this->assertEquals('string', $unitUnderTest->getType()); $unitUnderTest->setGroups(array('string', 'test')); $this->assertCount(2, $unitUnderTest->getGroups()); $this->assertEquals(array('string', 'test'), $unitUnderTest->getGroups()); }
/** * {@inheritDoc} * * @param string $className * @param string $file * @return null|ClassMetadata * @throws RuntimeException */ protected function loadMetadataFromFile($className, $file) { $config = Yaml::parse(file_get_contents($file)); if (!isset($config[$name = $className])) { throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $className, $file)); } $config = $config[$name]; $metadata = new ClassMetadata($name); $metadata->addFileResource($file); foreach ($config['properties'] as $propertyName => $propertyOptions) { $pMetadata = new PropertyMetadata($propertyName); if (isset($propertyOptions['expose'])) { $pMetadata->setExpose((bool) $propertyOptions['expose']); } if (isset($propertyOptions['serialized_name'])) { $pMetadata->setSerializedName((string) $propertyOptions['serialized_name']); } if (isset($propertyOptions['since_version'])) { $pMetadata->setSinceVersion((string) $propertyOptions['since_version']); } if (isset($propertyOptions['until_version'])) { $pMetadata->setUntilVersion((string) $propertyOptions['until_version']); } if (isset($propertyOptions['type'])) { $pMetadata->setType((string) $propertyOptions['type']); } if (isset($propertyOptions['groups'])) { $pMetadata->setGroups($propertyOptions['groups']); } if (isset($propertyOptions['null_skipped'])) { $pMetadata->setNullSkipped((bool) $propertyOptions['null_skipped']); } $metadata->addPropertyMetadata($pMetadata); } return $metadata; }