public function testCollect_OnConflictUpdate_UsesUpsertQuery(): void
{
- [$db, $command] = $this->createMockDbAndCommand();
+ $db = $this->createMock(\yii\db\Connection::class);
+ $command = $this->createMock(\yii\db\Command::class);
+
+ $db->method('createCommand')->willReturn($command);
+ $command->method('bindValues')->willReturnSelf();
+ $command->method('bindValue')->willReturnSelf();
$command->method('queryScalar')
->willReturnOnConsecutiveCalls(true, 1, 1, 1, 0, 0, 0, 1, true);
public function testCreatePartition_CreatesPartitionTable(): void
{
- [$db, $command] = $this->createMockDbAndCommand();
+ $db = $this->createMock(\yii\db\Connection::class);
+ $command = $this->createMock(\yii\db\Command::class);
+
+ $db->method('createCommand')->willReturn($command);
$executedSql = [];
$boundParams = [];
public function testEnsurePartitions_CreatesCurrentAndNextMonth(): void
{
- [$db, $command] = $this->createMockDbAndCommand();
+ $db = $this->createMock(\yii\db\Connection::class);
+ $command = $this->createMock(\yii\db\Command::class);
+
+ $db->method('createCommand')->willReturn($command);
$executedSql = [];
$command->method('setSql')->willReturnCallback(
public function testDropOldPartitions_DropsPartitionsOlderThanRetention(): void
{
- [$db, $command] = $this->createMockDbAndCommand();
+ $db = $this->createMock(\yii\db\Connection::class);
+ $command = $this->createMock(\yii\db\Command::class);
+
+ $db->method('createCommand')->willReturn($command);
+ $command->method('bindValues')->willReturnSelf();
+ $command->method('bindValue')->willReturnSelf();
$command->method('queryAll')->willReturn([
['tablename' => 'stock_history_2023_11'],