File tree 2 files changed +27
-0
lines changed
src/Symfony/Component/Config
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,18 @@ public function ifNull()
97
97
return $ this ;
98
98
}
99
99
100
+ /**
101
+ * Tests if the value is empty.
102
+ *
103
+ * @return ExprBuilder
104
+ */
105
+ public function ifEmpty ()
106
+ {
107
+ $ this ->ifPart = function ($ v ) { return empty ($ v ); };
108
+
109
+ return $ this ;
110
+ }
111
+
100
112
/**
101
113
* Tests if the value is an array.
102
114
*
Original file line number Diff line number Diff line change @@ -75,6 +75,21 @@ public function testIfNullExpression()
75
75
$ this ->assertFinalizedValueIs ('value ' , $ test );
76
76
}
77
77
78
+ public function testIfEmptyExpression ()
79
+ {
80
+ $ test = $ this ->getTestBuilder ()
81
+ ->ifEmpty ()
82
+ ->then ($ this ->returnClosure ('new_value ' ))
83
+ ->end ();
84
+ $ this ->assertFinalizedValueIs ('new_value ' , $ test , array ('key ' => array ()));
85
+
86
+ $ test = $ this ->getTestBuilder ()
87
+ ->ifEmpty ()
88
+ ->then ($ this ->returnClosure ('new_value ' ))
89
+ ->end ();
90
+ $ this ->assertFinalizedValueIs ('value ' , $ test );
91
+ }
92
+
78
93
public function testIfArrayExpression ()
79
94
{
80
95
$ test = $ this ->getTestBuilder ()
You can’t perform that action at this time.
0 commit comments