/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Database/DatabasePostgresQueryGrammarTest.php
70 строк
2 KB
Jason McCreary
[13.x] Mockery cleanup (#61117)
10 авг 2026, 20:23
Не верифицирован
10 авг 2026, 20:23
2ee40ee
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Database; use Illuminate\Database\Connection; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Grammars\PostgresGrammar; use Mockery; use PHPUnit\Framework\TestCase; class DatabasePostgresQueryGrammarTest extends TestCase { public function testToRawSql() { $connection = Mockery::mock(Connection::class); $connection->expects('escape')->with('foo', false)->andReturn("'foo'"); $grammar = new PostgresGrammar($connection); $query = $grammar->substituteBindingsIntoRawSql( 'select * from "users" where \'{}\' ?? \'Hello\\\'\\\'World?\' AND "email" = ?', ['foo'], ); $this->assertSame('select * from "users" where \'{}\' ? \'Hello\\\'\\\'World?\' AND "email" = \'foo\'', $query); } public function testCustomOperators() { PostgresGrammar::customOperators(['@@@', '@>', '']); PostgresGrammar::customOperators(['@@>', 1]); $connection = Mockery::mock(Connection::class); $grammar = new PostgresGrammar($connection); $operators = $grammar->getOperators(); $this->assertIsList($operators); $this->assertContains('@@@', $operators); $this->assertContains('@@>', $operators); $this->assertNotContains('', $operators); $this->assertNotContains(1, $operators); $this->assertSame(array_unique($operators), $operators); } public function testCompileTruncate() { $connection = Mockery::mock(Connection::class); $connection->expects('getTablePrefix')->times(3)->andReturn(''); $postgres = new PostgresGrammar($connection); $builder = Mockery::mock(Builder::class); $builder->from = 'users'; $this->assertEquals([ 'truncate "users" restart identity cascade' => [], ], $postgres->compileTruncate($builder)); PostgresGrammar::cascadeOnTruncate(false); $this->assertEquals([ 'truncate "users" restart identity' => [], ], $postgres->compileTruncate($builder)); PostgresGrammar::cascadeOnTruncate(); $this->assertEquals([ 'truncate "users" restart identity cascade' => [], ], $postgres->compileTruncate($builder)); } }