9 use \Magento\Framework\Config\Composer\Package;
14 '{"foo":"1","bar":"2","baz":["3","4"],"nested":{"one":"5","two":"6", 15 "magento/theme-adminhtml-backend":7, "magento/theme-frontend-luma":8}}';
29 $this->sampleJson = json_decode(self::SAMPLE_DATA);
30 $this->
object =
new Package($this->sampleJson);
35 $this->assertInstanceOf(
'\StdClass', $this->object->getJson(
false));
36 $this->assertEquals($this->sampleJson, $this->object->getJson(
false));
37 $this->assertSame($this->sampleJson, $this->object->getJson(
false));
39 json_encode($this->sampleJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) .
"\n",
40 $this->object->getJson(
true, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
46 $this->assertSame(
'1', $this->object->get(
'foo'));
47 $this->assertSame([
'3',
'4'], $this->object->get(
'baz'));
48 $nested = $this->
object->get(
'nested');
49 $this->assertInstanceOf(
'\StdClass', $nested);
50 $this->assertObjectHasAttribute(
'one', $nested);
51 $this->assertEquals(
'5', $nested->one);
52 $this->assertEquals(
'5', $this->object->get(
'nested->one'));
53 $this->assertObjectHasAttribute(
'two', $nested);
54 $this->assertEquals(
'6', $nested->two);
55 $this->assertEquals(
'6', $this->object->get(
'nested->two'));
57 [
'magento/theme-adminhtml-backend' => 7,
'magento/theme-frontend-luma' => 8],
58 (array)$this->object->get(
'nested',
'/^magento\/theme/')