@@ -14,35 +14,40 @@ protected function setUp(): void
14
14
{
15
15
parent ::setUp ();
16
16
17
- $ this ->setViewPath (__DIR__ . '/money ' );
17
+ $ this ->setViewPath (__DIR__ . '/templates ' );
18
18
19
19
IntlMoneyFormatter::directive ();
20
20
}
21
21
22
+ private static function replaceNonBreakingSpace (string $ value ): string
23
+ {
24
+ return str_replace ("\u{00A0}" , " " , $ value );
25
+ }
26
+
22
27
/** @test */
23
28
public function it_has_a_blade_directive_to_format_money ()
24
29
{
25
30
// @money(99)
26
- // $this->assertEquals('€ 0,99', $this->renderView('intl', ['cents' => 99]));
27
- // $this->assertEquals('€ 1,00', $this->renderView('intl', ['cents' => 100]));
28
- // $this->assertEquals('€ 1.000,00', $this->renderView('intl', ['cents' => 100 * 1000]));
31
+ $ this ->assertEquals ('€ 0,99 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 99 ]) ));
32
+ $ this ->assertEquals ('€ 1,00 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 100 ]) ));
33
+ $ this ->assertEquals ('€ 1.000,00 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 100 * 1000 ]) ));
29
34
30
35
// @money(99, 'USD')
31
- $ this ->assertEquals ('US$ 0,99 ' , $ this ->renderView ('intl ' , ['cents ' => 99 , 'code ' => 'USD ' ]));
32
- $ this ->assertEquals ('US$ 1,00 ' , $ this ->renderView ('intl ' , ['cents ' => 100 , 'code ' => 'USD ' ]));
33
- $ this ->assertEquals ('US$ 1.000,00 ' , $ this ->renderView ('intl ' , ['cents ' => 100 * 1000 , 'code ' => 'USD ' ]));
36
+ $ this ->assertEquals ('US$ 0,99 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 99 , 'code ' => 'USD ' ]) ));
37
+ $ this ->assertEquals ('US$ 1,00 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 100 , 'code ' => 'USD ' ]) ));
38
+ $ this ->assertEquals ('US$ 1.000,00 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 100 * 1000 , 'code ' => 'USD ' ]) ));
34
39
35
40
// or set a default
36
41
IntlMoneyFormatter::directive ('money ' , 'USD ' );
37
- $ this ->assertEquals ('US$ 0,99 ' , $ this ->renderView ('intl ' , ['cents ' => 99 ]));
42
+ $ this ->assertEquals ('US$ 0,99 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 99 ]) ));
38
43
39
44
// @money(99, 'USD', 'en')
40
- $ this ->assertEquals ('$0.99 ' , $ this ->renderView ('intl ' , ['cents ' => 99 , 'code ' => 'USD ' , 'locale ' => 'en ' ]));
41
- $ this ->assertEquals ('1,00 $ ' , $ this ->renderView ('intl ' , ['cents ' => 100 , 'code ' => 'USD ' , 'locale ' => 'de ' ]));
42
- $ this ->assertEquals ('1 000,00 $US ' , $ this ->renderView ('intl ' , ['cents ' => 100 * 1000 , 'code ' => 'USD ' , 'locale ' => 'fr ' ]));
45
+ $ this ->assertEquals ('$0.99 ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 99 , 'code ' => 'USD ' , 'locale ' => 'en ' ]) ));
46
+ $ this ->assertEquals ('1,00 $ ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 100 , 'code ' => 'USD ' , 'locale ' => 'de ' ]) ));
47
+ $ this ->assertEquals ('1 000,00 $US ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 100 * 1000 , 'code ' => 'USD ' , 'locale ' => 'fr ' ]) ));
43
48
44
49
// or set a default
45
50
IntlMoneyFormatter::directive ('money ' , 'USD ' , 'fr ' );
46
- $ this ->assertEquals ('1 000,00 $US ' , $ this ->renderView ('intl ' , ['cents ' => 100 * 1000 ]));
51
+ $ this ->assertEquals ('1 000,00 $US ' , static :: replaceNonBreakingSpace ( $ this ->renderView ('intl ' , ['cents ' => 100 * 1000 ]) ));
47
52
}
48
53
}
0 commit comments