Strings.endsWith().phpt 607 B

123456789101112131415161718192021222324
  1. <?php
  2. /**
  3. * Test: Nette\Utils\Strings::endsWith()
  4. */
  5. declare(strict_types=1);
  6. use Nette\Utils\Strings;
  7. use Tester\Assert;
  8. require __DIR__ . '/../bootstrap.php';
  9. Assert::exception(
  10. fn() => Strings::endsWith('123', null),
  11. TypeError::class,
  12. );
  13. Assert::true(Strings::endsWith('123', ''), "endsWith('123', '')");
  14. Assert::true(Strings::endsWith('123', '3'), "endsWith('123', '3')");
  15. Assert::false(Strings::endsWith('123', '2'), "endsWith('123', '2')");
  16. Assert::true(Strings::endsWith('123', '123'), "endsWith('123', '123')");
  17. Assert::false(Strings::endsWith('123', '1234'), "endsWith('123', '1234')");