Skip to content

Commit 84d433d

Browse files
committed
add checked helper
1 parent b8595b2 commit 84d433d

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ public function setUpRedis()
7676
*/
7777
public function tearDownRedis()
7878
{
79-
$this->redis['phpredis']->connection()->flushdb();
79+
if (isset($this->redis['phpredis'])) {
80+
$this->redis['phpredis']->connection()->flushdb();
81+
}
8082

8183
foreach ($this->redisDriverProvider() as $driver) {
82-
$this->redis[$driver[0]]->connection()->disconnect();
84+
if (isset($this->redis[$driver[0]])) {
85+
$this->redis[$driver[0]]->connection()->disconnect();
86+
}
8387
}
8488
}
8589

src/Illuminate/View/Compilers/Concerns/CompilesConditionals.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,15 @@ public function compileEndOnce()
304304
{
305305
return '<?php endif; ?>';
306306
}
307+
308+
/**
309+
* Compile a checked block into valid PHP.
310+
*
311+
* @param string $condition
312+
* @return string
313+
*/
314+
protected function compileChecked($condition)
315+
{
316+
return "<?php if{$condition}: echo 'checked'; endif; ?>";
317+
}
307318
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Illuminate\Tests\View\Blade;
4+
5+
class BladeCheckedStatementsTest extends AbstractBladeTestCase
6+
{
7+
public function testCheckedStatementsAreCompiled()
8+
{
9+
$string = '<input @checked(name(foo(bar)))/>';
10+
$expected = "<input <?php if(name(foo(bar))): echo 'checked'; endif; ?>/>";
11+
12+
$this->assertEquals($expected, $this->compiler->compileString($string));
13+
}
14+
}

0 commit comments

Comments
 (0)