Skip to content

Commit

Permalink
Add select commad test for SELECT...INTO
Browse files Browse the repository at this point in the history
Signed-off-by: pine3ree <[email protected]>
  • Loading branch information
pine3ree committed Oct 11, 2023
1 parent 282093b commit de1ac94
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/Command/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ public function testAggregateMethods()
);
}

public function testInto()
{
$select = $this->createSelectCommand($db);
$select->into('author')->from('user', 'u');
self::assertStringMatchesFormat("SELECT `u`.*%wINTO `author`%wFROM `user` `u`", $select->getSql());
}

/**
* @dataProvider provideJoinOptions
*/
Expand Down Expand Up @@ -746,4 +753,28 @@ public function testFetchColumn()
$this->pdoStatement->execute()->willReturn(false);
self::assertNull($select->fetchColumn(0));
}

public function testExecuteSuccessReturnsInt()
{
$select = $this->createSelectCommand($db);
$select->from('user');

$this->pdoStatement->rowCount()->willReturn(42);
$result = $select->into('author')->execute();
self::assertSame(42, $result);

$this->pdoStatement->rowCount()->willReturn(0);
$result = $select->into('author')->execute();
self::assertSame(0, $result);
}

public function testExecuteFailureReturnsFalse()
{
$select = $this->createSelectCommand($db);
$select->from('user');

$this->pdoStatement->execute()->willReturn(false);
$result = $select->into('author')->execute();
self::assertSame(false, $result);
}
}

0 comments on commit de1ac94

Please sign in to comment.