-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cover cases with RepositoryInterface
Add some test stubs to be used.
- Loading branch information
Showing
4 changed files
with
173 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,86 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Bake\Test\App\Model\NonTable; | ||
|
||
use Cake\Datasource\EntityInterface; | ||
use Cake\Datasource\RepositoryInterface; | ||
|
||
/** | ||
* An abstract non-table model with stubbed methods demanded by RepositoryInterface | ||
*/ | ||
abstract class AbstractNonTable implements RepositoryInterface | ||
{ | ||
public function setAlias(string $alias) | ||
{ | ||
} | ||
|
||
public function getAlias(): string | ||
{ | ||
return substr(static::class, strrpos(static::class, '\\') + 1); | ||
} | ||
|
||
public function setRegistryAlias(string $registryAlias) | ||
{ | ||
} | ||
|
||
public function getRegistryAlias(): string | ||
{ | ||
} | ||
|
||
public function hasField(string $field): bool | ||
{ | ||
} | ||
|
||
public function find(string $type = 'all', array $options = []) | ||
{ | ||
} | ||
|
||
public function get($primaryKey, array $options = []): EntityInterface | ||
{ | ||
} | ||
|
||
public function query() | ||
{ | ||
} | ||
|
||
public function updateAll($fields, $conditions): int | ||
{ | ||
} | ||
|
||
public function deleteAll($conditions): int | ||
{ | ||
} | ||
|
||
public function exists($conditions): bool | ||
{ | ||
} | ||
|
||
public function save(EntityInterface $entity, $options = []) | ||
{ | ||
} | ||
|
||
public function delete(EntityInterface $entity, $options = []): bool | ||
{ | ||
} | ||
|
||
public function newEmptyEntity(): EntityInterface | ||
{ | ||
} | ||
|
||
public function newEntity(array $data, array $options = []): EntityInterface | ||
{ | ||
} | ||
|
||
public function newEntities(array $data, array $options = []): array | ||
{ | ||
} | ||
|
||
public function patchEntity(EntityInterface $entity, array $data, array $options = []): EntityInterface | ||
{ | ||
} | ||
|
||
public function patchEntities(iterable $entities, array $data, array $options = []): array | ||
{ | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
tests/test_app/App/Model/NonTable/NonTableWithAssociations.php
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,41 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Bake\Test\App\Model\NonTable; | ||
|
||
use Cake\ORM\Association; | ||
use Cake\ORM\Association\BelongsTo; | ||
use Cake\ORM\AssociationCollection; | ||
|
||
/** | ||
* A non-table based model with associations | ||
*/ | ||
class NonTableWithAssociations extends AbstractNonTable | ||
{ | ||
protected $associations; | ||
|
||
/** | ||
* Get the associations collection for this table. | ||
* | ||
* @return \Cake\ORM\AssociationCollection The collection of association objects. | ||
*/ | ||
public function associations(): AssociationCollection | ||
{ | ||
$this->associations = new AssociationCollection(); | ||
|
||
$this->associations->load(BelongsTo::class, 'Users'); | ||
|
||
return $this->associations; | ||
} | ||
|
||
/** | ||
* Returns an association object configured for the specified alias. | ||
* | ||
* @param string $name The alias used for the association. | ||
* @return \Cake\ORM\Association The association. | ||
*/ | ||
public function getAssociation(string $name): Association | ||
{ | ||
return $this->associations->get($name); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/test_app/App/Model/NonTable/NonTableWithoutAssociations.php
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,11 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Bake\Test\App\Model\NonTable; | ||
|
||
/** | ||
* A non-table based model without associations | ||
*/ | ||
class NonTableWithoutAssociations extends AbstractNonTable | ||
{ | ||
} |