Strings.startsWith().phpt 631 B

123456789101112131415161718192021222324
  1. <?php
  2. /**
  3. * Test: Nette\Utils\Strings::startsWith()
  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::startsWith('123', null),
  11. TypeError::class,
  12. );
  13. Assert::true(Strings::startsWith('123', ''), "startsWith('123', '')");
  14. Assert::true(Strings::startsWith('123', '1'), "startsWith('123', '1')");
  15. Assert::false(Strings::startsWith('123', '2'), "startsWith('123', '2')");
  16. Assert::true(Strings::startsWith('123', '123'), "startsWith('123', '123')");
  17. Assert::false(Strings::startsWith('123', '1234'), "startsWith('123', '1234')");