Hoa central
Public Member Functions | List of all members
Hoa\String\Test\Unit\String Class Reference
Inheritance diagram for Hoa\String\Test\Unit\String:

Public Member Functions

 case_no_mbstring ()
 
 case_append_ltr ()
 
 case_append_rtl ()
 
 case_prepend_ltr ()
 
 case_prepend_rtl ()
 
 case_pad_beginning_ltr ()
 
 case_pad_beginning_rtl ()
 
 case_pad_end_ltr ()
 
 case_pad_end_rtl ()
 
 case_compare_no_collator ()
 
 case_compare ()
 
 case_collator ()
 
 case_safe_unsafe_pattern ()
 
 case_safe_safe_pattern ()
 
 case_match_default ()
 
 case_match_offset ()
 
 case_match_with_offset ()
 
 case_match_all_default ()
 
 case_match_all_with_offset ()
 
 case_match_all_grouped_by_pattern ()
 
 case_match_all_grouped_by_tuple ()
 
 case_replace ()
 
 case_replace_limited ()
 
 case_split_default ()
 
 case_split_default_limited ()
 
 case_split_with_delimiters ()
 
 case_split_with_offset ()
 
 case_iterator_ltr ()
 
 case_iterator_rtl ()
 
 case_to_lower ()
 
 case_to_upper ()
 
 case_trim_default ()
 
 case_trim_beginning ()
 
 case_trim_end ()
 
 case_offset_get_ltr ()
 
 case_offset_get_rtl ()
 
 case_offset_set ()
 
 case_offset_unset ()
 
 case_reduce ()
 
 case_count ()
 
 case_byte_at ()
 
 case_bytes_length ()
 
 case_get_width ()
 
 case_get_char_direction ()
 
 case_get_char_width ()
 
 case_is_char_printable ()
 
 case_from_code ()
 
 case_to_code ()
 
 case_to_binary_code ()
 
 case_transcode_and_isUtf8 ()
 
 case_to_ascii_no_transliterator_no_normalizer ()
 
 case_to_ascii_no_transliterator_no_normalizer_try ()
 
 case_to_ascii_no_transliterator ()
 
 case_to_ascii ()
 
 case_copy ()
 
 case_toString ()
 
- Public Member Functions inherited from Hoa\Test\Unit\Suite
 __construct ()
 
 getTestedClassName ()
 
 getTestedClassNamespace ()
 
 beforeTestMethod ($methodName)
 

Detailed Description

Class .

Test suite of the string class.

Definition at line 50 of file String.php.

Member Function Documentation

Hoa\String\Test\Unit\String::case_append_ltr ( )

Definition at line 66 of file String.php.

67  {
68  $this
69  ->given($string = new LUT('je'))
70  ->when($result = $string->append(' t\'aime'))
71  ->then
72  ->object($result)
73  ->isIdenticalTo($string)
74  ->string((string) $result)
75  ->isEqualTo('je t\'aime');
76  }
Hoa\String\Test\Unit\String::case_append_rtl ( )

Definition at line 78 of file String.php.

79  {
80  $this
81  ->given($string = new LUT('أ'))
82  ->when($result = $string->append('حبك'))
83  ->then
84  ->object($result)
85  ->isIdenticalTo($string)
86  ->string((string) $result)
87  ->isEqualTo('أحبك');
88  }
Hoa\String\Test\Unit\String::case_byte_at ( )

Definition at line 671 of file String.php.

672  {
673  $this
674  ->given($string = new LUT('💩'))
675  ->when($result = $string->getByteAt(0))
676  ->then
677  ->integer(ord($result))
678  ->isEqualTo(0xf0)
679 
680  ->when($result = $string->getByteAt(1))
681  ->then
682  ->integer(ord($result))
683  ->isEqualTo(0x9f)
684 
685  ->when($result = $string->getByteAt(2))
686  ->then
687  ->integer(ord($result))
688  ->isEqualTo(0x92)
689 
690  ->when($result = $string->getByteAt(3))
691  ->then
692  ->integer(ord($result))
693  ->isEqualTo(0xa9)
694 
695  ->when($result = $string->getByteAt(-1))
696  ->then
697  ->integer(ord($result))
698  ->isEqualTo(0xa9);
699  }
Hoa\String\Test\Unit\String::case_bytes_length ( )

Definition at line 701 of file String.php.

702  {
703  $this
704  ->given($string = new LUT('💩'))
705  ->when($result = $string->getBytesLength())
706  ->then
707  ->integer($result)
708  ->isEqualTo(4);
709  }
Hoa\String\Test\Unit\String::case_collator ( )

Definition at line 194 of file String.php.

195  {
196  $this
197  ->given(
198  $this->function->setlocale = 'fr_FR',
199  $collator = LUT::getCollator()
200  )
201  ->when($result = $collator->getLocale(\Locale::VALID_LOCALE))
202  ->then
203  ->string($result)
204  ->isEqualTo('fr');
205  }
Hoa\String\Test\Unit\String::case_compare ( )

Definition at line 174 of file String.php.

175  {
176  $this
177  ->given($string = new LUT('b'))
178  ->when($result = $string->compare('a'))
179  ->then
180  ->integer($result)
181  ->isEqualTo(1)
182 
183  ->when($result = $string->compare('b'))
184  ->then
185  ->integer($result)
186  ->isEqualTo(0)
187 
188  ->when($result = $string->compare('c'))
189  ->then
190  ->integer($result)
191  ->isEqualTo(-1);
192  }

Here is the caller graph for this function:

Hoa\String\Test\Unit\String::case_compare_no_collator ( )

Definition at line 162 of file String.php.

163  {
164  $this
165  ->given(
166  $this->function->class_exists = function ($name) {
167  return 'Collator' !== $name;
168  },
169  $string = new LUT('b')
170  )
171  ->case_compare();
172  }

Here is the call graph for this function:

Hoa\String\Test\Unit\String::case_copy ( )

Definition at line 1017 of file String.php.

1018  {
1019  $this
1020  ->given($string = new LUT('foo'))
1021  ->when($result = $string->copy())
1022  ->then
1023  ->object($result)
1024  ->isEqualTo($string);
1025  }
Hoa\String\Test\Unit\String::case_count ( )

Definition at line 649 of file String.php.

650  {
651  $this
652  ->given($string = new LUT('je t\'aime'))
653  ->when($result = count($string))
654  ->then
655  ->integer($result)
656  ->isEqualTo(9)
657 
658  ->given($string = new LUT('أحبك'))
659  ->when($result = count($string))
660  ->then
661  ->integer($result)
662  ->isEqualTo(4)
663 
664  ->given($string = new LUT('💩'))
665  ->when($result = count($string))
666  ->then
667  ->integer($result)
668  ->isEqualTo(1);
669  }
Hoa\String\Test\Unit\String::case_from_code ( )

Definition at line 811 of file String.php.

812  {
813  $this
814  // U+0000 to U+007F
815  ->when($result = LUT::fromCode(0x7e))
816  ->then
817  ->string($result)
818  ->isEqualTo('~')
819 
820  // U+0080 to U+07FF
821  ->when($result = LUT::fromCode(0xa7))
822  ->then
823  ->string($result)
824  ->isEqualTo('§')
825 
826  // U+0800 to U+FFFF
827  ->when($result = LUT::fromCode(0x1207))
828  ->then
829  ->string($result)
830  ->isEqualTo('ሇ')
831 
832  // U+10000 to U+10FFFF
833  ->when($result = LUT::fromCode(0x1f4a9))
834  ->then
835  ->string($result)
836  ->isEqualTo('💩');
837  }
Hoa\String\Test\Unit\String::case_get_char_direction ( )

Definition at line 727 of file String.php.

728  {
729  $this
730  ->when($result = LUT::getCharDirection('A'))
731  ->then
732  ->integer($result)
733  ->isEqualTo(LUT::LTR)
734 
735  ->when($result = LUT::getCharDirection('ا'))
736  ->then
737  ->integer($result)
738  ->isEqualTo(LUT::RTL);
739  }
Hoa\String\Test\Unit\String::case_get_char_width ( )

Definition at line 741 of file String.php.

742  {
743  $this
744  ->given(
745  $data = [
746  // 8-bit control character.
747  [0x0, 0],
748  [0x19, -1],
749  [0x7f, -1],
750  [0x9f, -1],
751 
752  // Regular.
753  [0xa0, 1],
754 
755  // Non-spacing characters mark.
756  [0x300, 0], // in Mn
757  [0x488, 0], // in Me
758  [0x600, 0], // in Cf
759  [0xad, 1], // in Cf, but the only exception
760  [0x1160, 0],
761  [0x11ff, 0],
762  [0x200b, 0],
763 
764  // To test the last return statement.
765  [0x1100, 2],
766  [0x2160, 1],
767  [0x3f60, 2],
768  [0x303f, 1],
769  [0x2329, 2],
770  [0xaed0, 2],
771  [0x232a, 2],
772  [0xffa4, 1],
773  [0xfe10, 2],
774  [0xfe30, 2],
775  [0xff00, 2],
776  [0xf900, 2]
777  ]
778  )
779  ->when(function () use ($data) {
780  foreach ($data as $datum) {
781  list($code, $width) = $datum;
782 
783  $this
784  ->when($result = LUT::getCharWidth(LUT::fromCode($code)))
785  ->then
786  ->integer($result)
787  ->isEqualTo($width);
788  }
789  });
790  }
Hoa\String\Test\Unit\String::case_get_width ( )

Definition at line 711 of file String.php.

712  {
713  $this
714  ->given($string = new LUT('💩'))
715  ->when($result = $string->getWidth())
716  ->then
717  ->integer($result)
718  ->isEqualTo(1)
719 
720  ->given($string = new LUT('習'))
721  ->when($result = $string->getWidth())
722  ->then
723  ->integer($result)
724  ->isEqualTo(2);
725  }
Hoa\String\Test\Unit\String::case_is_char_printable ( )

Definition at line 792 of file String.php.

793  {
794  $this
795  ->when($result = LUT::isCharPrintable(LUT::fromCode(0x7f)))
796  ->then
797  ->boolean($result)
798  ->isFalse()
799 
800  ->when($result = LUT::isCharPrintable(LUT::fromCode(0xa0)))
801  ->then
802  ->boolean($result)
803  ->isTrue()
804 
805  ->when($result = LUT::isCharPrintable(LUT::fromCode(0x1100)))
806  ->then
807  ->boolean($result)
808  ->isTrue();
809  }
Hoa\String\Test\Unit\String::case_iterator_ltr ( )

Definition at line 474 of file String.php.

475  {
476  $this
477  ->given($string = new LUT('je t\'aime'))
478  ->when($result = iterator_to_array($string))
479  ->then
480  ->array($result)
481  ->isEqualTo([
482  'j',
483  'e',
484  ' ',
485  't',
486  '\'',
487  'a',
488  'i',
489  'm',
490  'e'
491  ]);
492  }
Hoa\String\Test\Unit\String::case_iterator_rtl ( )

Definition at line 494 of file String.php.

495  {
496  $this
497  ->given($string = new LUT('أحبك'))
498  ->when($result = iterator_to_array($string))
499  ->then
500  ->array($result)
501  ->isEqualTo([
502  'أ',
503  'ح',
504  'ب',
505  'ك'
506  ]);
507  }
Hoa\String\Test\Unit\String::case_match_all_default ( )

Definition at line 293 of file String.php.

294  {
295  $this
296  ->given(
297  $pattern = '/💩/u',
298  $string = new LUT('foo 💩 bar 💩 baz')
299  )
300  ->when($result = $string->match($pattern, $matches, 0, 0, true))
301  ->then
302  ->integer($result)
303  ->isEqualTo(2)
304  ->array($matches)
305  ->isEqualTo([
306  0 => [
307  0 => '💩',
308  1 => '💩'
309  ]
310  ]);
311  }
Hoa\String\Test\Unit\String::case_match_all_grouped_by_pattern ( )

Definition at line 339 of file String.php.

340  {
341  $this
342  ->given(
343  $pattern = '/(💩)/u',
344  $string = new LUT('foo 💩 bar 💩 baz')
345  )
346  ->when($result = $string->match($pattern, $matches, $string::GROUP_BY_PATTERN, 0, true))
347  ->then
348  ->integer($result)
349  ->isEqualTo(2)
350  ->array($matches)
351  ->isEqualTo([
352  0 => [
353  0 => '💩',
354  1 => '💩'
355  ],
356  1 => [
357  0 => '💩',
358  1 => '💩'
359  ]
360  ]);
361  }
Hoa\String\Test\Unit\String::case_match_all_grouped_by_tuple ( )

Definition at line 363 of file String.php.

364  {
365  $this
366  ->given(
367  $pattern = '/(💩)/u',
368  $string = new LUT('foo 💩 bar 💩 baz')
369  )
370  ->when($result = $string->match($pattern, $matches, $string::GROUP_BY_TUPLE, 0, true))
371  ->then
372  ->integer($result)
373  ->isEqualTo(2)
374  ->array($matches)
375  ->isEqualTo([
376  0 => [
377  0 => '💩',
378  1 => '💩'
379  ],
380  1 => [
381  0 => '💩',
382  1 => '💩'
383  ]
384  ]);
385  }
Hoa\String\Test\Unit\String::case_match_all_with_offset ( )

Definition at line 313 of file String.php.

314  {
315  $this
316  ->given(
317  $pattern = '/💩/u',
318  $string = new LUT('foo 💩 bar 💩 baz')
319  )
320  ->when($result = $string->match($pattern, $matches, $string::WITH_OFFSET, 0, true))
321  ->then
322  ->integer($result)
323  ->isEqualTo(2)
324  ->array($matches)
325  ->isEqualTo([
326  0 => [
327  0 => [
328  0 => '💩',
329  1 => 4
330  ],
331  1 => [
332  0 => '💩',
333  1 => 13
334  ]
335  ]
336  ]);
337  }
Hoa\String\Test\Unit\String::case_match_default ( )

Definition at line 227 of file String.php.

228  {
229  $this
230  ->given(
231  $pattern = '/💩/u',
232  $string = new LUT('foo 💩 bar')
233  )
234  ->when($result = $string->match($pattern, $matches))
235  ->then
236  ->integer($result)
237  ->isEqualTo(1)
238  ->array($matches)
239  ->isEqualTo([
240  0 => '💩'
241  ]);
242  }
Hoa\String\Test\Unit\String::case_match_offset ( )

Definition at line 244 of file String.php.

245  {
246  $this
247  ->given(
248  $pattern = '/💩/u',
249  $string = new LUT('foo 💩 bar')
250  )
251  ->when($result = $string->match($pattern, $matches, 0, 0))
252  ->then
253  ->integer($result)
254  ->isEqualTo(1)
255  ->array($matches)
256  ->isEqualTo([0 => '💩'])
257 
258  ->when($result = $string->match($pattern, $matches, 0, 4))
259  ->then
260  ->integer($result)
261  ->isEqualTo(1)
262  ->array($matches)
263  ->isEqualTo([0 => '💩'])
264 
265  ->when($result = $string->match($pattern, $matches, 0, 5))
266  ->then
267  ->integer($result)
268  ->isEqualTo(0)
269  ->array($matches)
270  ->isEmpty();
271  }
Hoa\String\Test\Unit\String::case_match_with_offset ( )

Definition at line 273 of file String.php.

274  {
275  $this
276  ->given(
277  $pattern = '/💩/u',
278  $string = new LUT('foo 💩 bar')
279  )
280  ->when($result = $string->match($pattern, $matches, $string::WITH_OFFSET))
281  ->then
282  ->integer($result)
283  ->isEqualTo(1)
284  ->array($matches)
285  ->isEqualTo([
286  0 => [
287  0 => '💩',
288  1 => 4
289  ]
290  ]);
291  }
Hoa\String\Test\Unit\String::case_no_mbstring ( )

Definition at line 52 of file String.php.

53  {
54  $this
55  ->given(
56  $this->function->function_exists = function ($name) {
57  return 'mb_substr' !== $name;
58  }
59  )
60  ->exception(function () {
61  new LUT();
62  })
63  ->isInstanceOf('Hoa\String\Exception');
64  }
Hoa\String\Test\Unit\String::case_offset_get_ltr ( )

Definition at line 585 of file String.php.

586  {
587  $this
588  ->given($string = new LUT('je t\'aime'))
589  ->when($result = $string[0])
590  ->then
591  ->string($result)
592  ->isEqualTo('j')
593 
594  ->when($result = $string[-1])
595  ->then
596  ->string($result)
597  ->isEqualTo('e');
598  }
Hoa\String\Test\Unit\String::case_offset_get_rtl ( )

Definition at line 600 of file String.php.

601  {
602  $this
603  ->given($string = new LUT('أحبك'))
604  ->when($result = $string[0])
605  ->then
606  ->string($result)
607  ->isEqualTo('أ')
608 
609  ->when($result = $string[-1])
610  ->then
611  ->string($result)
612  ->isEqualTo('ك');
613  }
Hoa\String\Test\Unit\String::case_offset_set ( )

Definition at line 615 of file String.php.

616  {
617  $this
618  ->given($string = new LUT('أحبﻙ'))
619  ->when($string[-1] = 'ك')
620  ->then
621  ->string((string) $string)
622  ->isEqualTo('أحبك');
623  }
Hoa\String\Test\Unit\String::case_offset_unset ( )

Definition at line 625 of file String.php.

626  {
627  $this
628  ->given($string = new LUT('أحبك😄'))
629  ->when(function () use ($string) {
630  unset($string[-1]);
631  })
632  ->then
633  ->string((string) $string)
634  ->isEqualTo('أحبك');
635  }
Hoa\String\Test\Unit\String::case_pad_beginning_ltr ( )

Definition at line 114 of file String.php.

115  {
116  $this
117  ->given($string = new LUT('je t\'aime'))
118  ->when($result = $string->pad(20, '👍 💩 😄 ❤️ ', LUT::BEGINNING))
119  ->then
120  ->object($result)
121  ->isIdenticalTo($string)
122  ->string((string) $result)
123  ->isEqualTo('👍 💩 😄 ❤️ 👍 je t\'aime');
124  }
Hoa\String\Test\Unit\String::case_pad_beginning_rtl ( )

Definition at line 126 of file String.php.

127  {
128  $this
129  ->given($string = new LUT('أحبك'))
130  ->when($result = $string->pad(20, '👍 💩 😄 ❤️ ', LUT::BEGINNING))
131  ->then
132  ->object($result)
133  ->isIdenticalTo($string)
134  ->string((string) $result)
135  ->isEqualTo('👍 💩 😄 ❤️ 👍 💩 😄 ❤أحبك');
136  }
Hoa\String\Test\Unit\String::case_pad_end_ltr ( )

Definition at line 138 of file String.php.

139  {
140  $this
141  ->given($string = new LUT('je t\'aime'))
142  ->when($result = $string->pad(20, '👍 💩 😄 ❤️ ', LUT::END))
143  ->then
144  ->object($result)
145  ->isIdenticalTo($string)
146  ->string((string) $result)
147  ->isEqualTo('je t\'aime👍 💩 😄 ❤️ 👍 ');
148  }
Hoa\String\Test\Unit\String::case_pad_end_rtl ( )

Definition at line 150 of file String.php.

151  {
152  $this
153  ->given($string = new LUT('أحبك'))
154  ->when($result = $string->pad(20, '👍 💩 😄 ❤️ ', LUT::END))
155  ->then
156  ->object($result)
157  ->isIdenticalTo($string)
158  ->string((string) $result)
159  ->isEqualTo('أحبك👍 💩 😄 ❤️ 👍 💩 😄 ❤');
160  }
Hoa\String\Test\Unit\String::case_prepend_ltr ( )

Definition at line 90 of file String.php.

91  {
92  $this
93  ->given($string = new LUT(' t\'aime'))
94  ->when($result = $string->prepend('je'))
95  ->then
96  ->object($result)
97  ->isIdenticalTo($string)
98  ->string((string) $result)
99  ->isEqualTo('je t\'aime');
100  }
Hoa\String\Test\Unit\String::case_prepend_rtl ( )

Definition at line 102 of file String.php.

103  {
104  $this
105  ->given($string = new LUT('ك'))
106  ->when($result = $string->prepend('أحب'))
107  ->then
108  ->object($result)
109  ->isIdenticalTo($string)
110  ->string((string) $result)
111  ->isEqualTo('أحبك');
112  }
Hoa\String\Test\Unit\String::case_reduce ( )

Definition at line 637 of file String.php.

638  {
639  $this
640  ->given($string = new LUT('أحبك'))
641  ->when($result = $string->reduce(0, 1))
642  ->then
643  ->object($result)
644  ->isIdenticalTo($string)
645  ->string((string) $result)
646  ->isEqualTo('أ');
647  }
Hoa\String\Test\Unit\String::case_replace ( )

Definition at line 387 of file String.php.

388  {
389  $this
390  ->given($string = new LUT('❤️ 💩 💩'))
391  ->when($result = $string->replace('/💩/u', '😄'))
392  ->then
393  ->object($result)
394  ->isIdenticalTo($string)
395  ->string((string) $result)
396  ->isEqualTo('❤️ 😄 😄');
397  }
Hoa\String\Test\Unit\String::case_replace_limited ( )

Definition at line 399 of file String.php.

400  {
401  $this
402  ->given($string = new LUT('❤️ 💩 💩'))
403  ->when($result = $string->replace('/💩/u', '😄', 1))
404  ->then
405  ->object($result)
406  ->isIdenticalTo($string)
407  ->string((string) $result)
408  ->isEqualTo('❤️ 😄 💩');
409  }
Hoa\String\Test\Unit\String::case_safe_safe_pattern ( )

Definition at line 217 of file String.php.

218  {
219  $this
220  ->given($pattern = '/foo/ui')
221  ->when($result = LUT::safePattern($pattern))
222  ->then
223  ->string($result)
224  ->isEqualto('/foo/ui');
225  }
Hoa\String\Test\Unit\String::case_safe_unsafe_pattern ( )

Definition at line 207 of file String.php.

208  {
209  $this
210  ->given($pattern = '/foo/i')
211  ->when($result = LUT::safePattern($pattern))
212  ->then
213  ->string($result)
214  ->isEqualto('/foo/iu');
215  }
Hoa\String\Test\Unit\String::case_split_default ( )

Definition at line 411 of file String.php.

412  {
413  $this
414  ->given($string = new LUT('❤️💩❤️💩❤️'))
415  ->when($result = $string->split('/💩/'))
416  ->then
417  ->array($result)
418  ->isEqualTo([
419  0 => '❤️',
420  1 => '❤️',
421  2 => '❤️'
422  ]);
423  }
Hoa\String\Test\Unit\String::case_split_default_limited ( )

Definition at line 425 of file String.php.

426  {
427  $this
428  ->given($string = new LUT('❤️💩❤️💩❤️'))
429  ->when($result = $string->split('/💩/', 1))
430  ->then
431  ->array($result)
432  ->isEqualTo([
433  0 => '❤️💩❤️💩❤️'
434  ]);
435  }
Hoa\String\Test\Unit\String::case_split_with_delimiters ( )

Definition at line 437 of file String.php.

438  {
439  $this
440  ->given($string = new LUT('❤️💩❤️💩❤️'))
441  ->when($result = $string->split('/💩/', -1, $string::WITH_DELIMITERS))
442  ->then
443  ->array($result)
444  ->isEqualTo([
445  0 => '❤️',
446  1 => '❤️',
447  2 => '❤️'
448  ]);
449  }
Hoa\String\Test\Unit\String::case_split_with_offset ( )

Definition at line 451 of file String.php.

452  {
453  $this
454  ->given($string = new LUT('❤️💩❤️💩❤️'))
455  ->when($result = $string->split('/💩/', -1, $string::WITH_OFFSET))
456  ->then
457  ->array($result)
458  ->isEqualTo([
459  0 => [
460  0 => '❤️',
461  1 => 0
462  ],
463  1 => [
464  0 => '❤️',
465  1 => 10
466  ],
467  2 => [
468  0 => '❤️',
469  1 => 20
470  ]
471  ]);
472  }
Hoa\String\Test\Unit\String::case_to_ascii ( )

Definition at line 964 of file String.php.

965  {
966  $this
967  ->given(
968  $strings = [
969  'Un été brûlant sur la côte'
970  => 'Un ete brulant sur la cote',
971 
972  'Αυτή είναι μια δοκιμή'
973  => 'Aute einai mia dokime',
974 
975  'أحبك'
976  => 'ahbk',
977 
978  'キャンパス'
979  => 'kyanpasu',
980 
981  'биологическом'
982  => 'biologiceskom',
983 
984  '정, 병호'
985  => 'jeong, byeongho',
986 
987  'ますだ, よしひこ'
988  => 'masuda, yoshihiko',
989 
990  'मोनिच'
991  => 'monica',
992 
993  'क्ष'
994  => 'ksa',
995 
996  'أحبك 😀'
997  => 'ahbk (grinning face)',
998 
999  '∀ i ∈ ℕ'
1000  => '(for all) i (element of) N'
1001  ]
1002  )
1003  ->when(function () use ($strings) {
1004  foreach ($strings as $original => $asciied) {
1005  $this
1006  ->given($string = new LUT($original))
1007  ->when($result = $string->toAscii())
1008  ->then
1009  ->object($result)
1010  ->isIdenticalTo($string)
1011  ->string((string) $result)
1012  ->isEqualTo($asciied);
1013  }
1014  });
1015  }
Hoa\String\Test\Unit\String::case_to_ascii_no_transliterator ( )

Definition at line 947 of file String.php.

948  {
949  $this
950  ->given(
951  $this->function->class_exists = function ($name) {
952  return 'Transliterator' !== $name;
953  },
954  $string = new LUT('Un été brûlant sur la côte')
955  )
956  ->when($result = $string->toAscii())
957  ->then
958  ->object($result)
959  ->isIdenticalTo($string)
960  ->string((string) $result)
961  ->isEqualTo('Un ete brulant sur la cote');
962  }
Hoa\String\Test\Unit\String::case_to_ascii_no_transliterator_no_normalizer ( )

Definition at line 915 of file String.php.

916  {
917  $this
918  ->given(
919  $this->function->class_exists = function ($name) {
920  return false === in_array($name, ['Transliterator', 'Normalizer']);
921  },
922  $string = new LUT('Un été brûlant sur la côte')
923  )
924  ->exception(function () use ($string) {
925  $string->toAscii();
926  })
927  ->isInstanceOf('Hoa\String\Exception');
928  }
Hoa\String\Test\Unit\String::case_to_ascii_no_transliterator_no_normalizer_try ( )

Definition at line 930 of file String.php.

931  {
932  $this
933  ->given(
934  $this->function->class_exists = function ($name) {
935  return false === in_array($name, ['Transliterator', 'Normalizer']);
936  },
937  $string = new LUT('Un été brûlant sur la côte')
938  )
939  ->when($result = $string->toAscii(true))
940  ->then
941  ->object($result)
942  ->isIdenticalTo($string)
943  ->string((string) $result)
944  ->isEqualTo('Un ete brulant sur la cote');
945  }
Hoa\String\Test\Unit\String::case_to_binary_code ( )

Definition at line 867 of file String.php.

868  {
869  $this
870  // U+0000 to U+007F
871  ->when($result = LUT::toBinaryCode('~'))
872  ->then
873  ->string($result)
874  ->isEqualTo('01111110')
875 
876  // U+0080 to U+07FF
877  ->when($result = LUT::toBinaryCode('§'))
878  ->then
879  ->string($result)
880  ->isEqualTo('1100001010100111')
881 
882  // U+0800 to U+FFFF
883  ->when($result = LUT::toBinaryCode('ሇ'))
884  ->then
885  ->string($result)
886  ->isEqualTo('111000011000100010000111')
887 
888  // U+10000 to U+10FFFF
889  ->when($result = LUT::toBinaryCode('💩'))
890  ->then
891  ->string($result)
892  ->isEqualTo('11110000100111111001001010101001');
893  }
Hoa\String\Test\Unit\String::case_to_code ( )

Definition at line 839 of file String.php.

840  {
841  $this
842  // U+0000 to U+007F
843  ->when($result = LUT::toCode('~'))
844  ->then
845  ->integer($result)
846  ->isEqualTo(0x7e)
847 
848  // U+0080 to U+07FF
849  ->when($result = LUT::toCode('§'))
850  ->then
851  ->integer($result)
852  ->isEqualTo(0xa7)
853 
854  // U+0800 to U+FFFF
855  ->when($result = LUT::toCode('ሇ'))
856  ->then
857  ->integer($result)
858  ->isEqualTo(0x1207)
859 
860  // U+10000 to U+10FFFF
861  ->when($result = LUT::toCode('💩'))
862  ->then
863  ->integer($result)
864  ->isEqualTo(0x1f4a9);
865  }
Hoa\String\Test\Unit\String::case_to_lower ( )

Definition at line 509 of file String.php.

510  {
511  $this
512  ->given($string = new LUT('Σ \'ΑΓΑΠΏ'))
513  ->when($result = $string->toLowerCase())
514  ->then
515  ->object($result)
516  ->isIdenticalTo($string)
517  ->string((string) $result)
518  ->isEqualTo('σ \'αγαπώ')
519 
520  ->given($string = new LUT('JE T\'AIME'))
521  ->when($result = $string->toLowerCase())
522  ->then
523  ->object($result)
524  ->isIdenticalTo($string)
525  ->string((string) $result)
526  ->isEqualTo('je t\'aime');
527  }
Hoa\String\Test\Unit\String::case_to_upper ( )

Definition at line 529 of file String.php.

530  {
531  $this
532  ->given($string = new LUT('σ \'αγαπώ'))
533  ->when($result = $string->toUpperCase())
534  ->then
535  ->object($result)
536  ->isIdenticalTo($string)
537  ->string((string) $result)
538  ->isEqualTo('Σ \'ΑΓΑΠΏ')
539 
540  ->given($string = new LUT('je t\'aime'))
541  ->when($result = $string->toUpperCase())
542  ->then
543  ->object($result)
544  ->isIdenticalTo($string)
545  ->string((string) $result)
546  ->isEqualTo('JE T\'AIME');
547  }
Hoa\String\Test\Unit\String::case_toString ( )

Definition at line 1027 of file String.php.

1028  {
1029  $this
1030  ->given($datum = $this->sample($this->realdom->regex('/\w{7,42}/')))
1031  ->when($result = new LUT($datum))
1032  ->then
1033  ->castToString($result)
1034  ->isEqualTo($datum);
1035  }
Hoa\String\Test\Unit\String::case_transcode_and_isUtf8 ( )

Definition at line 895 of file String.php.

896  {
897  $this
898  ->given($uΣ = 'Σ')
899  ->when($Σ = LUT::transcode($uΣ, 'UTF-8', 'UTF-16'))
900  ->then
901  ->string($Σ)
902  ->isNotEqualTo($uΣ)
903  ->boolean(LUT::isUtf8($Σ))
904  ->isFalse()
905 
906  ->when($Σ = LUT::transcode($Σ, 'UTF-16', 'UTF-8'))
907  ->string($Σ)
908  ->isEqualTo($uΣ)
909  ->boolean(LUT::isUtf8($Σ))
910  ->isTrue()
911  ->boolean(LUT::isUtf8($uΣ))
912  ->isTrue();
913  }
Hoa\String\Test\Unit\String::case_trim_beginning ( )

Definition at line 561 of file String.php.

562  {
563  $this
564  ->given($string = new LUT('💩💩❤️💩💩'))
565  ->when($result = $string->trim('💩', $string::BEGINNING))
566  ->then
567  ->object($result)
568  ->isIdenticalTo($string)
569  ->string((string) $result)
570  ->isEqualTo('❤️💩💩');
571  }
Hoa\String\Test\Unit\String::case_trim_default ( )

Definition at line 549 of file String.php.

550  {
551  $this
552  ->given($string = new LUT('💩💩❤️💩💩'))
553  ->when($result = $string->trim('💩'))
554  ->then
555  ->object($result)
556  ->isIdenticalTo($string)
557  ->string((string) $result)
558  ->isEqualTo('❤️');
559  }
Hoa\String\Test\Unit\String::case_trim_end ( )

Definition at line 573 of file String.php.

574  {
575  $this
576  ->given($string = new LUT('💩💩❤️💩💩'))
577  ->when($result = $string->trim('💩', $string::END))
578  ->then
579  ->object($result)
580  ->isIdenticalTo($string)
581  ->string((string) $result)
582  ->isEqualTo('💩💩❤️');
583  }

The documentation for this class was generated from the following file: