Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d7f7734

Browse files
committed
Merge pull request laravel#2069 from Chumper/4.0
Config Repository fails on a true value due to weak comparison
2 parents 129e0c5 + 8bb04ff commit d7f7734

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/Illuminate/Config/Repository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function has($key)
6464
{
6565
$default = microtime(true);
6666

67-
return $this->get($key, $default) != $default;
67+
return $this->get($key, $default) !== $default;
6868
}
6969

7070
/**
@@ -324,7 +324,7 @@ public function getLoader()
324324
{
325325
return $this->loader;
326326
}
327-
327+
328328
/**
329329
* Set the loader implementation.
330330
*

tests/Config/ConfigRepositoryTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ public function testHasGroupIndicatesIfConfigGroupExists()
1818
}
1919

2020

21+
public function testHasOnTrueReturnsTrue()
22+
{
23+
$config = $this->getRepository();
24+
$options = $this->getDummyOptions();
25+
$config->getLoader()->shouldReceive('load')->once()->with('production', 'app', null)->andReturn($options);
26+
27+
$this->assertTrue($config->has('app.bing'));
28+
$this->assertEquals(true,$config->get('app.bing'));
29+
}
30+
31+
2132
public function testGetReturnsBasicItems()
2233
{
2334
$config = $this->getRepository();
@@ -128,7 +139,7 @@ protected function getRepository()
128139

129140
protected function getDummyOptions()
130141
{
131-
return array('foo' => 'bar', 'baz' => array('boom' => 'breeze'));
142+
return array('foo' => 'bar', 'baz' => array('boom' => 'breeze'), 'bing' => true);
132143
}
133144

134145
}

0 commit comments

Comments
 (0)