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

MockTreeWalker should be an SqlWalker #9790

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions tests/Doctrine/Tests/Mocks/MockTreeWalker.php

This file was deleted.

41 changes: 41 additions & 0 deletions tests/Doctrine/Tests/Mocks/NullSqlWalker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\Mocks;

use Doctrine\DBAL\Connection;
use Doctrine\ORM\Query\AST;
use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
use Doctrine\ORM\Query\SqlWalker;

/**
* SqlWalker implementation that does not produce SQL.
*/
class NullSqlWalker extends SqlWalker
{
public function walkSelectStatement(AST\SelectStatement $AST): string
{
return '';
}

public function walkUpdateStatement(AST\UpdateStatement $AST): string
{
return '';
}

public function walkDeleteStatement(AST\DeleteStatement $AST): string
{
return '';
}

public function getExecutor($AST): AbstractSqlExecutor
{
return new class extends AbstractSqlExecutor {
public function execute(Connection $conn, array $params, array $types): int
{
return 0;
}
};
}
}
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\ParserResult;
use Doctrine\ORM\Query\QueryException;
use Doctrine\Tests\Mocks\MockTreeWalker;
use Doctrine\Tests\Mocks\NullSqlWalker;
use Doctrine\Tests\OrmTestCase;

use const PHP_EOL;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function parseDql(string $dql, array $hints = []): ParserResult
$parser = new Query\Parser($query);

// We do NOT test SQL output here. That only unnecessarily slows down the tests!
$parser->setCustomOutputTreeWalker(MockTreeWalker::class);
$parser->setCustomOutputTreeWalker(NullSqlWalker::class);

return $parser->parse();
}
Expand Down