Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Nov 20, 2024
1 parent 3d44dff commit ece7af0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Each table column has its own class in the `Yiisoft\Db\Schema\Column` namespace
- `QuoterInterface::getRawTableName()` - returns the raw table name without quotes;
- `SchemaInterface::getColumnFactory()` - returns the column factory object for concrete DBMS;
- `QueryBuilderInterface::buildColumnDefinition()` - builds column definition for `CREATE TABLE` statement;
- `QueryBuilderInterface::prepareParam()` - converts a {@see ParamInterface} object to its SQL representation;
- `QueryBuilderInterface::prepareParam()` - converts a `ParamInterface` object to its SQL representation;
- `QueryBuilderInterface::prepareValue()` - converts a value to its SQL representation;

### Remove methods
Expand Down
13 changes: 0 additions & 13 deletions tests/AbstractQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2433,17 +2433,4 @@ public function testPrepareValue(string $expected, mixed $value): void

$this->assertSame($expected, $qb->prepareValue($value));
}

public function testPrepareValueClosedResource(): void
{
$db = $this->getConnection();
$qb = $db->getQueryBuilder();

$this->expectExceptionObject(new InvalidArgumentException('Resource is closed.'));

$resource = fopen('php://memory', 'r');
fclose($resource);

$qb->prepareValue($resource);
}
}
27 changes: 27 additions & 0 deletions tests/Db/QueryBuilder/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
use Yiisoft\Db\Tests\Support\Stub\Schema;
use Yiisoft\Db\Tests\Support\TestTrait;

use function fclose;
use function fopen;
use function stream_context_create;

/**
* @group db
*
Expand Down Expand Up @@ -314,4 +318,27 @@ public function testUpsertExecute(
$actualParams = [];
$actualSQL = $db->getQueryBuilder()->upsert($table, $insertColumns, $updateColumns, $actualParams);
}

public function testPrepareValueClosedResource(): void
{
$db = $this->getConnection();
$qb = $db->getQueryBuilder();

$this->expectExceptionObject(new InvalidArgumentException('Resource is closed.'));

$resource = fopen('php://memory', 'r');
fclose($resource);

$qb->prepareValue($resource);
}

public function testPrepareValueNonSteamResource(): void
{
$db = $this->getConnection();
$qb = $db->getQueryBuilder();

$this->expectExceptionObject(new InvalidArgumentException('Supported only stream resource type.'));

$qb->prepareValue(stream_context_create());
}
}

0 comments on commit ece7af0

Please sign in to comment.