Commit 937a55f4 by Carsten Brandt

fixed unit test for sqlite

parent f153ce44
<?php
namespace yiiunit\framework\db\sqlite;
use yiiunit\data\ar\Customer;
use yiiunit\framework\db\ActiveRecordTest;
/**
......@@ -10,4 +11,34 @@ use yiiunit\framework\db\ActiveRecordTest;
class SqliteActiveRecordTest extends ActiveRecordTest
{
protected $driverName = 'sqlite';
/**
* Some PDO implementations(e.g. cubrid) do not support boolean values.
* Make sure this does not affect AR layer.
*/
public function testBooleanAttribute()
{
$customer = new Customer();
$customer->name = 'boolean customer';
$customer->email = 'mail@example.com';
$customer->status = true;
$customer->save(false);
$customer->refresh();
$this->assertEquals(1, $customer->status);
$customer->status = false;
$customer->save(false);
$customer->refresh();
// sqlite will return empty string here but it would still
// evaluate to false or null so we accept it
$this->assertTrue(0 == $customer->status);
$customers = Customer::find()->where(['status' => true])->all();
$this->assertEquals(2, count($customers));
$customers = Customer::find()->where(['status' => false])->all();
$this->assertEquals(1, count($customers));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment