Skip to content
Permalink
Browse files

Fix broken dot notation access in A::get

  • Loading branch information...
bastianallgeier committed Apr 23, 2019
1 parent bd8a252 commit c9dcfb5a79af7951a6be6dcecd202d9c8a01b28e
Showing with 15 additions and 3 deletions.
  1. +5 −1 src/Toolkit/A.php
  2. +4 −0 tests/Cms/RouterTest.php
  3. +6 −2 tests/Toolkit/ATest.php
@@ -100,7 +100,11 @@ public static function get($array, $key, $default = null)
return $default;
}
return static::get($array[$firstKey], implode('.', $keys), $default);
if (is_array($array[$firstKey]) === true) {
return static::get($array[$firstKey], implode('.', $keys), $default);
}
return $default;
}
return $default;
@@ -272,6 +272,10 @@ public function testDisabledApi()
$this->assertNull($app->call('api'));
$this->assertNull($app->call('api/something'));
// the api route should still be there
$patterns = array_column($app->routes(), 'pattern');
$this->assertEquals('api/(:all)', $patterns[0]);
}
public function testDisabledPanel()
@@ -34,10 +34,12 @@ public function testGet()
// fallback value
$this->assertEquals(null, A::get($array, 'elephant'));
$this->assertEquals('toot', A::get($array, 'elephant', 'toot'));
$this->assertEquals([
'cat' => 'miao',
'elephant' => null,
], A::get($array, ['cat', 'elephant']));
$this->assertEquals([
'cat' => 'miao',
'elephant' => 'toot',
@@ -52,7 +54,7 @@ public function testGetWithDotNotation()
'child' => $child = 'a',
'another.child' => $anotherChild = 'b',
]
]
],
];
$this->assertEquals($grandma, A::get($data, 'grand.ma'));
@@ -61,7 +63,9 @@ public function testGetWithDotNotation()
$this->assertEquals($anotherChild, A::get($data, 'grand.ma.mother.another.child'));
// with default
$this->assertEquals('default', A::get($data, 'grandma.mother.sister', 'default'));
$this->assertEquals('default', A::get($data, 'grand', 'default'));
$this->assertEquals('default', A::get($data, 'grand.ma.mother.sister', 'default'));
$this->assertEquals('default', A::get($data, 'grand.ma.mother.child.grandchild', 'default'));
}
public function testMerge()

0 comments on commit c9dcfb5

Please sign in to comment.
You can’t perform that action at this time.