Doctrine\Tests\ODM\PHPCR\Translation\AttributeTranslationStrategyTest::testGetLocalesFor PHP Method

testGetLocalesFor() public method

public testGetLocalesFor ( )
    public function testGetLocalesFor()
    {
        if (version_compare(PHP_VERSION, '5.3.3', '<=')) {
            $this->markTestSkipped('Prophesize does not work on PHP 5.3.3');
        }
        $classMetadata = $this->prophesize('Doctrine\\ODM\\PHPCR\\Mapping\\ClassMetadata');
        $document = new \stdClass();
        $localizedPropNames = array('test:de-prop1' => 'de', 'test:de_at-prop2' => 'de_at', 'test:en_Hans_CN_nedis_rozaj_x_prv1_prv2-prop3' => 'en_Hans_CN_nedis_rozaj_x_prv1_prv2', 'i18n:de-asdf' => false, 'asdf' => false, 'de_asdf' => false);
        $node = $this->prophesize('PHPCR\\NodeInterface');
        $properties = array();
        foreach (array_keys($localizedPropNames) as $localizedPropName) {
            $property = $this->prophesize('PHPCR\\PropertyInterface');
            $property->getName()->willReturn($localizedPropName);
            $properties[] = $property->reveal();
        }
        $node->getProperties('test:*')->willReturn($properties);
        $locales = $this->strategy->getLocalesFor($document, $node->reveal(), $classMetadata->reveal());
        $expected = array_values(array_filter($localizedPropNames, function ($valid) {
            return $valid;
        }));
        $this->assertEquals($expected, $locales);
    }