@@ -277,6 +277,31 @@ public function testWhenEndsWith()
277
277
}));
278
278
}
279
279
280
+ public function testWhenDoesntEndWith ()
281
+ {
282
+ $ this ->assertSame ('Tony Stark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntEndWith ('ark ' , function ($ stringable ) {
283
+ return $ stringable ->studly ();
284
+ }, function ($ stringable ) {
285
+ return $ stringable ->title ();
286
+ }));
287
+
288
+ $ this ->assertSame ('Tony Stark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntEndWith (['kra ' , 'ark ' ], function ($ stringable ) {
289
+ return $ stringable ->studly ();
290
+ }, function ($ stringable ) {
291
+ return $ stringable ->title ();
292
+ }));
293
+
294
+ $ this ->assertSame ('tony stark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntEndWith (['xxx ' ], function ($ stringable ) {
295
+ return $ stringable ;
296
+ }));
297
+
298
+ $ this ->assertSame ('TonyStark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntEndWith (['tony ' , 'xxx ' ], function ($ stringable ) {
299
+ return $ stringable ->studly ();
300
+ }, function ($ stringable ) {
301
+ return $ stringable ->title ();
302
+ }));
303
+ }
304
+
280
305
public function testWhenExactly ()
281
306
{
282
307
$ this ->assertSame ('Nailed it...! ' , (string ) $ this ->stringable ('Tony Stark ' )->whenExactly ('Tony Stark ' , function ($ stringable ) {
@@ -437,6 +462,31 @@ public function testWhenStartsWith()
437
462
}));
438
463
}
439
464
465
+ public function testWhenDoesntStartWith ()
466
+ {
467
+ $ this ->assertSame ('Tony Stark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntStartWith ('ton ' , function ($ stringable ) {
468
+ return $ stringable ->studly ();
469
+ }, function ($ stringable ) {
470
+ return $ stringable ->title ();
471
+ }));
472
+
473
+ $ this ->assertSame ('Tony Stark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntStartWith (['ton ' , 'not ' ], function ($ stringable ) {
474
+ return $ stringable ->studly ();
475
+ }, function ($ stringable ) {
476
+ return $ stringable ->title ();
477
+ }));
478
+
479
+ $ this ->assertSame ('tony stark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntStartWith (['xxx ' ], function ($ stringable ) {
480
+ return $ stringable ;
481
+ }));
482
+
483
+ $ this ->assertSame ('Tony Stark ' , (string ) $ this ->stringable ('tony stark ' )->whenDoesntStartWith (['tony ' , 'xxx ' ], function ($ stringable ) {
484
+ return $ stringable ->studly ();
485
+ }, function ($ stringable ) {
486
+ return $ stringable ->title ();
487
+ }));
488
+ }
489
+
440
490
public function testWhenEmpty ()
441
491
{
442
492
tap ($ this ->stringable (), function ($ stringable ) {
@@ -598,6 +648,36 @@ public function testStartsWith()
598
648
$ this ->assertFalse ($ this ->stringable ('Malmö ' )->startsWith ('Malmo ' ));
599
649
}
600
650
651
+ public function testDoesntStartWith ()
652
+ {
653
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntStartWith ('jas ' ));
654
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntStartWith ('jason ' ));
655
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntStartWith (['jas ' ]));
656
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntStartWith (['day ' , 'jas ' ]));
657
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntStartWith (collect (['day ' , 'jas ' ])));
658
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntStartWith ('day ' ));
659
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntStartWith (['day ' ]));
660
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntStartWith (null ));
661
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntStartWith ([null ]));
662
+ $ this ->assertTrue ($ this ->stringable ('0123 ' )->doesntStartWith ([null ]));
663
+ $ this ->assertFalse ($ this ->stringable ('0123 ' )->doesntStartWith (0 ));
664
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntStartWith ('J ' ));
665
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntStartWith ('' ));
666
+ $ this ->assertTrue ($ this ->stringable ('7 ' )->doesntStartWith (' 7 ' ));
667
+ $ this ->assertFalse ($ this ->stringable ('7a ' )->doesntStartWith ('7 ' ));
668
+ $ this ->assertFalse ($ this ->stringable ('7a ' )->doesntStartWith (7 ));
669
+ $ this ->assertFalse ($ this ->stringable ('7.12a ' )->doesntStartWith (7.12 ));
670
+ $ this ->assertTrue ($ this ->stringable ('7.12a ' )->doesntStartWith (7.13 ));
671
+ $ this ->assertFalse ($ this ->stringable (7.123 )->doesntStartWith ('7 ' ));
672
+ $ this ->assertFalse ($ this ->stringable (7.123 )->doesntStartWith ('7.12 ' ));
673
+ $ this ->assertTrue ($ this ->stringable (7.123 )->doesntStartWith ('7.13 ' ));
674
+ // Test for multibyte string support
675
+ $ this ->assertFalse ($ this ->stringable ('Jönköping ' )->doesntStartWith ('Jö ' ));
676
+ $ this ->assertFalse ($ this ->stringable ('Malmö ' )->doesntStartWith ('Malmö ' ));
677
+ $ this ->assertTrue ($ this ->stringable ('Jönköping ' )->doesntStartWith ('Jonko ' ));
678
+ $ this ->assertTrue ($ this ->stringable ('Malmö ' )->doesntStartWith ('Malmo ' ));
679
+ }
680
+
601
681
public function testEndsWith ()
602
682
{
603
683
$ this ->assertTrue ($ this ->stringable ('jason ' )->endsWith ('on ' ));
@@ -626,6 +706,34 @@ public function testEndsWith()
626
706
$ this ->assertFalse ($ this ->stringable ('Malmö ' )->endsWith ('mo ' ));
627
707
}
628
708
709
+ public function testDoesntEndWith ()
710
+ {
711
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntEndWith ('on ' ));
712
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntEndWith ('jason ' ));
713
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntEndWith (['on ' ]));
714
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntEndWith (['no ' , 'on ' ]));
715
+ $ this ->assertFalse ($ this ->stringable ('jason ' )->doesntEndWith (collect (['no ' , 'on ' ])));
716
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntEndWith ('no ' ));
717
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntEndWith (['no ' ]));
718
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntEndWith ('' ));
719
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntEndWith ([null ]));
720
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntEndWith (null ));
721
+ $ this ->assertTrue ($ this ->stringable ('jason ' )->doesntEndWith ('N ' ));
722
+ $ this ->assertTrue ($ this ->stringable ('7 ' )->doesntEndWith (' 7 ' ));
723
+ $ this ->assertFalse ($ this ->stringable ('a7 ' )->doesntEndWith ('7 ' ));
724
+ $ this ->assertFalse ($ this ->stringable ('a7 ' )->doesntEndWith (7 ));
725
+ $ this ->assertFalse ($ this ->stringable ('a7.12 ' )->doesntEndWith (7.12 ));
726
+ $ this ->assertTrue ($ this ->stringable ('a7.12 ' )->doesntEndWith (7.13 ));
727
+ $ this ->assertFalse ($ this ->stringable (0.27 )->doesntEndWith ('7 ' ));
728
+ $ this ->assertFalse ($ this ->stringable (0.27 )->doesntEndWith ('0.27 ' ));
729
+ $ this ->assertTrue ($ this ->stringable (0.27 )->doesntEndWith ('8 ' ));
730
+ // Test for multibyte string support
731
+ $ this ->assertFalse ($ this ->stringable ('Jönköping ' )->doesntEndWith ('öping ' ));
732
+ $ this ->assertFalse ($ this ->stringable ('Malmö ' )->doesntEndWith ('mö ' ));
733
+ $ this ->assertTrue ($ this ->stringable ('Jönköping ' )->doesntEndWith ('oping ' ));
734
+ $ this ->assertTrue ($ this ->stringable ('Malmö ' )->doesntEndWith ('mo ' ));
735
+ }
736
+
629
737
public function testExcerpt ()
630
738
{
631
739
$ this ->assertSame ('...is a beautiful morn... ' , (string ) $ this ->stringable ('This is a beautiful morning ' )->excerpt ('beautiful ' , ['radius ' => 5 ]));
0 commit comments