Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for non-table model types (2.x) #953

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Command/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Cake\Core\Configure;
use Cake\Core\Exception\CakeException;
use Cake\Core\Plugin;
use Cake\Datasource\RepositoryInterface;
use Cake\Filesystem\Filesystem;
use Cake\Http\Response;
use Cake\Http\ServerRequest as Request;
Expand Down Expand Up @@ -459,19 +460,22 @@
/**
* Process a model, pull out model name + associations converted to fixture names.
*
* @param \Cake\ORM\Table $subject A Model class to scan for associations and pull fixtures off of.
* @param \Cake\Datasource\RepositoryInterface $subject A Model class to scan for associations and pull fixtures off of.
* @return void
*/
protected function _processModel(Table $subject): void
protected function _processModel(RepositoryInterface $subject): void
{
$this->_addFixture($subject->getAlias());
if (!method_exists($subject, 'associations')) {
return;
}
foreach ($subject->associations()->keys() as $alias) {
$assoc = $subject->getAssociation($alias);

Check failure on line 473 in src/Command/TestCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

Call to an undefined method Cake\Datasource\RepositoryInterface::getAssociation().
$target = $assoc->getTarget();
$name = $target->getAlias();
$subjectClass = get_class($subject);

if ($subjectClass !== Table::class && $subjectClass === get_class($target)) {

Check failure on line 478 in src/Command/TestCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

Result of && is always false.

Check failure on line 478 in src/Command/TestCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

Strict comparison using === between *NEVER* and class-string|false will always evaluate to false.

Check failure on line 478 in src/Command/TestCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

RedundantCondition

src/Command/TestCommand.php:478:17: RedundantCondition: Cake\ORM\Table::class can never contain class-string<Cake\Datasource\RepositoryInterface&object{associations()}> (see https://psalm.dev/122)
continue;
}
if (!isset($this->_fixtures[$name])) {
Expand Down
Loading