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

#951 Support for non-table model types #952

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Command/TestCommand.php
Expand Up @@ -23,6 +23,7 @@
use Cake\Core\Configure;
use Cake\Core\Exception\CakeException;
use Cake\Core\Plugin;
use Cake\Datasource\RepositoryInterface;
use Cake\Http\ServerRequest as Request;
use Cake\ORM\Table;
use Cake\Utility\Filesystem;
Expand Down Expand Up @@ -453,19 +454,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;

Check warning on line 464 in src/Command/TestCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/TestCommand.php#L464

Added line #L464 was not covered by tests
}
foreach ($subject->associations()->keys() as $alias) {
$assoc = $subject->getAssociation($alias);

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

View workflow job for this annotation

GitHub Actions / cs-stan / 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 472 in src/Command/TestCommand.php

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

Result of && is always false.

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

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

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

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

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

RedundantCondition

src/Command/TestCommand.php:472: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