File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,20 @@ public function store($locale)
75
75
}
76
76
}
77
77
78
+ /**
79
+ * Set the supported locales.
80
+ *
81
+ * @param array $locales
82
+ *
83
+ * @return \CodeZero\Localizer\Localizer
84
+ */
85
+ public function setSupportedLocales (array $ locales )
86
+ {
87
+ $ this ->locales = $ locales ;
88
+
89
+ return $ this ;
90
+ }
91
+
78
92
/**
79
93
* Check if the given locale is supported.
80
94
*
Original file line number Diff line number Diff line change @@ -99,4 +99,20 @@ public function it_accepts_class_names_instead_of_instances_in_the_constructor()
99
99
$ localizer ->detect ();
100
100
$ localizer ->store ('nl ' );
101
101
}
102
+
103
+ /** @test */
104
+ public function you_can_set_the_supported_locales_at_runtime ()
105
+ {
106
+ $ supportedLocales = ['en ' ];
107
+ $ detectors = [
108
+ Mockery::mock (Detector::class)->allows ()->detect ()->andReturns ('en ' )->getMock (),
109
+ Mockery::mock (Detector::class)->allows ()->detect ()->andReturns ('nl ' )->getMock (),
110
+ ];
111
+
112
+ $ localizer = new Localizer ($ supportedLocales , $ detectors );
113
+ $ value = $ localizer ->setSupportedLocales (['nl ' ]);
114
+
115
+ $ this ->assertEquals ('nl ' , $ localizer ->detect ());
116
+ $ this ->assertEquals ($ localizer , $ value );
117
+ }
102
118
}
You can’t perform that action at this time.
0 commit comments