@@ -65,20 +65,20 @@ public function testTexts(): void
6565 // Test placeholders
6666 $ locale ->setDefault ('en-US ' );
6767
68- $ this ->assertEquals ('Hello Matej Bačo! ' , $ locale ->getText ('helloPlaceholder ' , [
68+ $ this ->assertEquals ('Hello Matej Bačo! ' , $ locale ->getText ('helloPlaceholder ' , placeholders: [
6969 'name ' => 'Matej ' ,
7070 'surname ' => 'Bačo ' ,
7171 ]));
72- $ this ->assertEquals ('Hello Matej {{surname}}! ' , $ locale ->getText ('helloPlaceholder ' , [
72+ $ this ->assertEquals ('Hello Matej {{surname}}! ' , $ locale ->getText ('helloPlaceholder ' , placeholders: [
7373 'name ' => 'Matej ' ,
7474 ]));
7575 $ this ->assertEquals ('Hello {{name}} {{surname}}! ' , $ locale ->getText ('helloPlaceholder ' ));
7676
77- $ this ->assertEquals ('We have 12 users registered. ' , $ locale ->getText ('numericPlaceholder ' , [
77+ $ this ->assertEquals ('We have 12 users registered. ' , $ locale ->getText ('numericPlaceholder ' , placeholders: [
7878 'usersAmount ' => 6 + 6 ,
7979 ]));
8080
81- $ this ->assertEquals ('Lets repeat: Appwrite, Appwrite, Appwrite ' , $ locale ->getText ('multiplePlaceholders ' , [
81+ $ this ->assertEquals ('Lets repeat: Appwrite, Appwrite, Appwrite ' , $ locale ->getText ('multiplePlaceholders ' , placeholders: [
8282 'word ' => 'Appwrite ' ,
8383 ]));
8484
@@ -120,4 +120,15 @@ public function testFallback(): void
120120 $ this ->assertInstanceOf (Exception::class, $ e );
121121 }
122122 }
123+
124+ public function testGetTextDefault (): void
125+ {
126+ $ locale = new Locale ('en-US ' );
127+
128+ $ this ->assertEquals ('Hello ' , $ locale ->getText ('hello ' ));
129+ $ this ->assertEquals ('{{missing}} ' , $ locale ->getText ('missing ' ));
130+ $ this ->assertEquals ('A custom text ' , $ locale ->getText ('missing ' , default: 'A custom text ' ));
131+ $ this ->assertEquals (null , $ locale ->getText ('missing ' , default: null ));
132+ $ this ->assertEquals ('Sorry Matej, missing text ' , $ locale ->getText ('missing ' , placeholders: ['name ' => 'Matej ' ], default: 'Sorry {{name}}, missing text ' ));
133+ }
123134}
0 commit comments