-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve exception message and add test
- Loading branch information
Showing
2 changed files
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\PhpGenerator\ClassType; | ||
use Nette\PhpGenerator\EnumType; | ||
use Nette\PhpGenerator\InterfaceType; | ||
use Nette\PhpGenerator\TraitType; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
require __DIR__ . '/fixtures/classes.php'; | ||
|
||
Assert::exception(function () { | ||
ClassType::from(Abc\Interface1::class); | ||
}, Nette\InvalidArgumentException::class, "'Abc\\Interface1' cannot be represented with Nette\\PhpGenerator\\ClassType. Call Nette\\PhpGenerator\\InterfaceType::from() or Nette\\PhpGenerator\\ClassLike::from() instead."); | ||
|
||
Assert::exception(function () { | ||
TraitType::from(Abc\Class1::class); | ||
}, Nette\InvalidArgumentException::class, "'Abc\\Class1' cannot be represented with Nette\\PhpGenerator\\TraitType. Call Nette\\PhpGenerator\\ClassType::from() or Nette\\PhpGenerator\\ClassLike::from() instead."); | ||
|
||
Assert::exception(function () { | ||
ClassType::fromCode("<?php interface I {}"); | ||
}, Nette\InvalidArgumentException::class, "Provided code cannot be represented with Nette\\PhpGenerator\\ClassType. Call Nette\\PhpGenerator\\InterfaceType::fromCode() or Nette\\PhpGenerator\\ClassLike::fromCode() instead."); | ||
|
||
Assert::exception(function () { | ||
InterfaceType::fromCode("<?php trait T {}"); | ||
}, Nette\InvalidArgumentException::class, "Provided code cannot be represented with Nette\\PhpGenerator\\InterfaceType. Call Nette\\PhpGenerator\\TraitType::fromCode() or Nette\\PhpGenerator\\ClassLike::fromCode() instead."); |