Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test against
EntityInterface
instead of self
Classes consuming `EntityTrait` do not necessarily have to extend `Entity`, testing against `self` would fail in various cases, like for example when one of the compared objects extends `Entity` and the other just implements `EntityInterface`.
- Loading branch information
ndm2
committed
Dec 11, 2014
1 parent
19931dd
commit 333ed72
Showing
5 changed files
with
66 additions
and
32 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
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,46 @@ | ||
<?php | ||
|
||
namespace TestApp\Model\Entity; | ||
|
||
use Cake\Datasource\EntityInterface; | ||
use Cake\Datasource\EntityTrait; | ||
|
||
/** | ||
* Tests entity class used for asserting correct loading | ||
* | ||
*/ | ||
class NonExtending implements EntityInterface { | ||
|
||
use EntityTrait; | ||
|
||
public function __construct(array $properties = [], array $options = []) { | ||
$options += [ | ||
'useSetters' => true, | ||
'markClean' => false, | ||
'markNew' => null, | ||
'guard' => false, | ||
'source' => null | ||
]; | ||
$this->_className = get_class($this); | ||
|
||
if (!empty($properties)) { | ||
$this->set($properties, [ | ||
'setter' => $options['useSetters'], | ||
'guard' => $options['guard'] | ||
]); | ||
} | ||
|
||
if ($options['markClean']) { | ||
$this->clean(); | ||
} | ||
|
||
if ($options['markNew'] !== null) { | ||
$this->isNew($options['markNew']); | ||
} | ||
|
||
if (!empty($options['source'])) { | ||
$this->source($options['source']); | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.