Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from inlm/pr/bugfix-property-read
EntityReflection: property name must be unique
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 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,78 @@ | ||
<?php | ||
|
||
use LeanMapper\Entity; | ||
use Tester\Assert; | ||
|
||
require_once __DIR__ . '/../bootstrap.php'; | ||
|
||
////////// | ||
|
||
/** | ||
* @property string $web (website) | ||
* @property string $site (website) | ||
*/ | ||
class AuthorWithDuplicatedColumn extends Entity | ||
{ | ||
} | ||
|
||
Assert::exception( | ||
function () { | ||
$reflection = AuthorWithDuplicatedColumn::getReflection(); | ||
}, | ||
'LeanMapper\Exception\InvalidStateException', | ||
"Mapping collision in property 'site' (column 'website') in entity AuthorWithDuplicatedColumn. Please fix mapping or make chosen properties read only (using property-read)." | ||
); | ||
|
||
////////// | ||
|
||
/** | ||
* @property int $id | ||
* @property string $id | ||
*/ | ||
class AuthorWithDuplicatedProperty1 extends Entity | ||
{ | ||
} | ||
|
||
Assert::exception( | ||
function () { | ||
$reflection = AuthorWithDuplicatedProperty1::getReflection(); | ||
}, | ||
'LeanMapper\Exception\InvalidStateException', | ||
"Duplicated property 'id' in entity AuthorWithDuplicatedProperty1. Please fix property name." | ||
); | ||
|
||
////////// | ||
|
||
/** | ||
* @property int $id | ||
* @property string $id (name) | ||
*/ | ||
class AuthorWithDuplicatedProperty2 extends Entity | ||
{ | ||
} | ||
|
||
Assert::exception( | ||
function () { | ||
$reflection = AuthorWithDuplicatedProperty2::getReflection(); | ||
}, | ||
'LeanMapper\Exception\InvalidStateException', | ||
"Duplicated property 'id' in entity AuthorWithDuplicatedProperty2. Please fix property name." | ||
); | ||
|
||
////////// | ||
|
||
/** | ||
* @property int $id | ||
* @property-read string $id | ||
*/ | ||
class AuthorWithDuplicatedReadProperty extends Entity | ||
{ | ||
} | ||
|
||
Assert::exception( | ||
function () { | ||
$reflection = AuthorWithDuplicatedReadProperty::getReflection(); | ||
}, | ||
'LeanMapper\Exception\InvalidStateException', | ||
"Duplicated property 'id' in entity AuthorWithDuplicatedReadProperty. Please fix property name." | ||
); |