StaticClass.phpt 511 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Test: Nette\StaticClass
  4. */
  5. declare(strict_types=1);
  6. use Tester\Assert;
  7. require __DIR__ . '/../bootstrap.php';
  8. class TestClass
  9. {
  10. use Nette\StaticClass;
  11. public static function method()
  12. {
  13. }
  14. }
  15. Assert::exception(
  16. fn() => new TestClass,
  17. Error::class,
  18. 'Call to private TestClass::__construct() from global scope',
  19. );
  20. Assert::exception(
  21. fn() => TestClass::methodA(),
  22. Nette\MemberAccessException::class,
  23. 'Call to undefined static method TestClass::methodA(), did you mean method()?',
  24. );