Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Aug 29, 2024
1 parent 6a305d4 commit 5688929
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 1 addition & 3 deletions tests/ActiveQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2045,9 +2045,7 @@ public function testOptimisticLockAfterDelete(): void
$document->delete();
}

/**
* {@see https://github.com/yiisoft/yii2/issues/9006}
*/
/** @link https://github.com/yiisoft/yii2/issues/9006 */
public function testBit(): void
{
$this->checkFixture($this->db(), 'bit_values');
Expand Down
7 changes: 2 additions & 5 deletions tests/Driver/Oracle/ActiveQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,16 @@ public function testJoinWithSameTable(): void
$this->assertTrue($orders[0]->isRelationPopulated('itemsIndexed'));
}

/**
* @see https://github.com/yiisoft/yii2/issues/9006
*/
public function testBit(): void
{
$this->checkFixture($this->db(), 'bit_values');

$bitValueQuery = new ActiveQuery(BitValues::class);
$falseBit = $bitValueQuery->findOne(1);
$this->assertEquals('0', $falseBit->val);
$this->assertSame('0', $falseBit->val);

$bitValueQuery = new ActiveQuery(BitValues::class);
$trueBit = $bitValueQuery->findOne(2);
$this->assertEquals('1', $trueBit->val);
$this->assertSame('1', $trueBit->val);
}
}
15 changes: 15 additions & 0 deletions tests/Driver/Pgsql/ActiveQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Yiisoft\ActiveRecord\Tests\Driver\Pgsql;

use Yiisoft\ActiveRecord\ActiveQuery;
use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\BitValues;
use Yiisoft\ActiveRecord\Tests\Support\PgsqlHelper;
use Yiisoft\Db\Connection\ConnectionInterface;

Expand All @@ -13,4 +15,17 @@ protected function createConnection(): ConnectionInterface
{
return (new PgsqlHelper())->createConnection();
}

public function testBit(): void
{
$this->checkFixture($this->db(), 'bit_values');

$bitValueQuery = new ActiveQuery(BitValues::class);
$falseBit = $bitValueQuery->findOne(1);
$this->assertSame(0, $falseBit->val);

$bitValueQuery = new ActiveQuery(BitValues::class);
$trueBit = $bitValueQuery->findOne(2);
$this->assertSame(1, $trueBit->val);
}
}
4 changes: 2 additions & 2 deletions tests/data/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ CREATE TABLE `type` (
`blob_col` blob,
`numeric_col` decimal(5,2) DEFAULT '33.22',
`time` timestamp NOT NULL DEFAULT '2002-01-01 00:00:00',
`bool_col` tinyint(1) NOT NULL,
`bool_col2` tinyint(1) DEFAULT '1',
`bool_col` bit(1) NOT NULL,
`bool_col2` bit(1) DEFAULT b'1',
`ts_default` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`bit_col` BIT(8) NOT NULL DEFAULT b'10000010',
`json_col` json
Expand Down

0 comments on commit 5688929

Please sign in to comment.