1212use Testo \Assert \Api \Builtin \ObjectType ;
1313use Testo \Assert \Api \Builtin \StringType ;
1414use Testo \Assert \Api \Json \JsonAbstract ;
15+ use Testo \Assert \Internal \Assertion \AssertArray ;
1516use Testo \Assert \Internal \Assertion \AssertFloat ;
1617use Testo \Assert \Internal \Assertion \AssertInt ;
18+ use Testo \Assert \Internal \Assertion \AssertIterable ;
1719use Testo \Assert \Internal \Assertion \AssertJson ;
1820use Testo \Assert \Internal \Assertion \AssertObject ;
1921use Testo \Assert \Internal \Assertion \AssertString ;
20- use Testo \Assert \Internal \Assertion \AssertArray ;
2122use Testo \Assert \State \AssertException ;
22- use Testo \Assert \State \AssertTypeFailure ;
23+ use Testo \Assert \State \Assertion \AssertionException ;
24+ use Testo \Assert \State \Test \Fail ;
2325use Testo \Assert \StaticState ;
2426use Testo \Assert \Support ;
25- use Testo \Assert \Internal \Assertion \AssertIterable ;
2627
2728/**
2829 * Assertion utilities.
@@ -40,7 +41,7 @@ final class Assert
4041 public static function same (mixed $ expected , mixed $ actual , string $ message = '' ): void
4142 {
4243 $ actual === $ expected
43- ? StaticState::log ( ' Assert same: ` ' . Support:: stringify ( $ expected ) . ' ` ' , $ message )
44+ ? StaticState::success ( $ actual , ' is the same ' , $ message )
4445 : StaticState::fail (AssertException::compare ($ expected , $ actual , $ message ));
4546 }
4647
@@ -55,7 +56,7 @@ public static function same(mixed $expected, mixed $actual, string $message = ''
5556 public static function notSame (mixed $ expected , mixed $ actual , string $ message = '' ): void
5657 {
5758 $ actual !== $ expected
58- ? StaticState::log ( ' Assert not same: ` ' . Support::stringify ($ expected ) . '` ' , $ message )
59+ ? StaticState::success ( $ actual , ' is not same as ` ' . Support::stringify ($ expected ) . '` ' , $ message )
5960 : StaticState::fail (AssertException::compare (
6061 $ expected ,
6162 $ actual ,
@@ -76,7 +77,7 @@ public static function notSame(mixed $expected, mixed $actual, string $message =
7677 public static function equals (mixed $ expected , mixed $ actual , string $ message = '' ): void
7778 {
7879 $ actual == $ expected
79- ? StaticState::log ( ' Assert equals: ` ' . Support::stringify ($ expected ) . '` ' , $ message )
80+ ? StaticState::success ( $ actual , ' equals to ` ' . Support::stringify ($ expected ) . '` ' , $ message )
8081 : StaticState::fail (AssertException::compare (
8182 $ expected ,
8283 $ actual ,
@@ -96,7 +97,7 @@ public static function equals(mixed $expected, mixed $actual, string $message =
9697 public static function notEquals (mixed $ expected , mixed $ actual , string $ message = '' ): void
9798 {
9899 $ actual != $ expected
99- ? StaticState::log ( ' Assert not equals: ` ' . Support::stringify ($ expected ) . '` ' , $ message )
100+ ? StaticState::success ( $ actual , ' is not equals to ` ' . Support::stringify ($ expected ) . '` ' , $ message )
100101 : StaticState::fail (AssertException::compare (
101102 $ expected ,
102103 $ actual ,
@@ -107,38 +108,38 @@ public static function notEquals(mixed $expected, mixed $actual, string $message
107108 }
108109
109110 /**
110- * Asserts that the condition is true.
111+ * Asserts that the value is true.
111112 *
112- * @param bool $condition The condition asserting to be true .
113+ * @param mixed $actual The actual value to check .
113114 * @param string $message Short description about what exactly is being asserted.
114115 * @throws AssertException when the assertion fails.
115116 */
116- public static function true (bool $ condition , string $ message = '' ): void
117+ public static function true (mixed $ actual , string $ message = '' ): void
117118 {
118- $ condition === true
119- ? StaticState::log ( ' Assert true ' , $ message )
119+ $ actual === true
120+ ? StaticState::success ( $ actual , ' is exactly ` true` ' , $ message )
120121 : StaticState::fail (AssertException::compare (
121122 true ,
122- $ condition ,
123+ $ actual ,
123124 $ message ,
124125 'Failed asserting that value `%2$s` is `%1$s` ' ,
125126 ));
126127 }
127128
128129 /**
129- * Asserts that the condition is false.
130+ * Asserts that the value is false.
130131 *
131- * @param bool $condition The condition asserting to be false .
132+ * @param mixed $actual The actual value to check .
132133 * @param string $message Short description about what exactly is being asserted.
133134 * @throws AssertException when the assertion fails.
134135 */
135- public static function false (bool $ condition , string $ message = '' ): void
136+ public static function false (mixed $ actual , string $ message = '' ): void
136137 {
137- $ condition === false
138- ? StaticState::log ( ' Assert false ' , $ message )
138+ $ actual === false
139+ ? StaticState::success ( $ actual , ' is exactly ` false` ' , $ message )
139140 : StaticState::fail (AssertException::compare (
140141 false ,
141- $ condition ,
142+ $ actual ,
142143 $ message ,
143144 'Failed asserting that value `%2$s` is `%1$s` ' ,
144145 ));
@@ -174,7 +175,7 @@ public static function contains(mixed $needle, iterable $haystack, string $messa
174175 {
175176 foreach ($ haystack as $ element ) {
176177 if ($ needle === $ element ) {
177- StaticState::log ( ' Assert contains ' , $ message );
178+ StaticState::success ( $ haystack , ' contains ` ' . Support:: stringify ( $ needle ) . ' ` ' , $ message );
178179 return ;
179180 }
180181 }
@@ -198,7 +199,7 @@ public static function null(
198199 string $ message = '' ,
199200 ): void {
200201 $ actual === null
201- ? StaticState::log ( ' Assert `null` ' , $ message )
202+ ? StaticState::success ( $ actual , ' is exactly `null` ' , $ message )
202203 : StaticState::fail (AssertException::compare (null , $ actual , $ message ));
203204 }
204205
@@ -221,7 +222,7 @@ public static function blank(
221222 if (
222223 $ actual === null || $ actual === '' || $ actual === [] || ($ actual instanceof \Countable && \count ($ actual ) === 0 )
223224 ) {
224- StaticState::log ( ' Assert blank ' , $ message );
225+ StaticState::success ( $ actual , ' is blank ' , $ message );
225226 return ;
226227 }
227228 StaticState::fail (AssertException::compare (
@@ -245,7 +246,7 @@ public static function string(mixed $actual): StringType
245246 /**
246247 * Asserts that the given value is of `int` data type.
247248 *
248- * @throws AssertTypeFailure
249+ * @throws AssertionException
249250 */
250251 public static function int (mixed $ actual ): IntType
251252 {
@@ -255,7 +256,7 @@ public static function int(mixed $actual): IntType
255256 /**
256257 * Asserts that the given value is of `float` data type.
257258 *
258- * @throws AssertTypeFailure
259+ * @throws AssertionException
259260 */
260261 public static function float (mixed $ actual ): FloatType
261262 {
@@ -267,7 +268,7 @@ public static function float(mixed $actual): FloatType
267268 *
268269 * Numeric type includes integer, float, and numeric strings.
269270 *
270- * @throws AssertTypeFailure
271+ * @throws AssertionException
271272 *
272273 * @deprecated To be implemented
273274 */
@@ -295,7 +296,7 @@ public static function json(string $actual): JsonAbstract
295296 * Iterables include arrays and objects implementing iterable interface.
296297 * Does not work with Generators.
297298 *
298- * @throws AssertTypeFailure
299+ * @throws AssertionException
299300 */
300301 public static function iterable (mixed $ actual ): IterableType
301302 {
@@ -305,7 +306,7 @@ public static function iterable(mixed $actual): IterableType
305306 /**
306307 * Asserts that the given value is of `array` data type.
307308 *
308- * @throws AssertTypeFailure
309+ * @throws AssertionException
309310 */
310311 public static function array (mixed $ actual ): ArrayType
311312 {
@@ -315,7 +316,7 @@ public static function array(mixed $actual): ArrayType
315316 /**
316317 * Asserts that the given value is of `object` data type.
317318 *
318- * @throws AssertTypeFailure
319+ * @throws AssertionException
319320 *
320321 * @deprecated To be implemented
321322 */
@@ -337,7 +338,7 @@ public static function object(mixed $actual): ObjectType
337338 */
338339 public static function fail (string $ message = '' ): never
339340 {
340- $ exception = AssertException:: fail ($ message );
341+ $ exception = new Fail ($ message );
341342 StaticState::expectFail ($ exception );
342343 StaticState::fail ($ exception );
343344 }
0 commit comments