/** * Test that the locale meta data is parsed correctly. * If the bundle has a parent, also test that the values between the two are merged correctly. */ public function testGetLocale() { $parent = $this->parent->allConfig(); $formats = $this->formats->allConfig(); $inflections = $this->inflections->allConfig(); $validations = $this->validations->allConfig(); // Parent $this->assertTrue(is_array($parent)); $this->assertArraysEqual(['code' => 'ex', 'language' => 'ex', 'iso2' => 'ex', 'iso3' => 'exp', 'timezone' => '', 'title' => 'Example Parent', 'initialize' => false], $parent); // Formats $this->assertTrue(is_array($formats)); $this->assertArraysEqual(['code' => 'ex_FM', 'language' => 'ex', 'region' => 'FM', 'iso2' => 'ex', 'iso3' => ['exf', 'frm'], 'timezone' => '', 'title' => 'Example for Formats', 'parent' => 'ex', 'initialize' => false], $formats); // Inflections $this->assertTrue(is_array($inflections)); $this->assertArraysEqual(['code' => 'ex_IN', 'language' => 'ex', 'region' => 'IN', 'iso2' => 'ex', 'iso3' => 'inf', 'timezone' => '', 'title' => 'Example for Inflections', 'parent' => 'ex', 'initialize' => false], $inflections); // Validations $this->assertTrue(is_array($validations)); $this->assertArraysEqual(['code' => 'ex_VA', 'language' => 'ex', 'region' => 'VA', 'iso2' => 'ex', 'iso3' => 'val', 'timezone' => '', 'title' => 'Example for Validations', 'parent' => 'ex', 'initialize' => false], $validations); // By key $this->assertEquals('ex', $this->parent->getConfig('code')); $this->assertEquals('ex', $this->parent->getConfig('iso2')); $this->assertEquals('exp', $this->parent->getConfig('iso3')); $this->assertEquals('', $this->parent->getConfig('timezone')); try { $this->parent->getConfig('fakeKey'); $this->assertTrue(false); } catch (Exception $e) { $this->assertTrue(true); } }