Skip to content

Instantly share code, notes, and snippets.

@RusAlex
Created July 23, 2015 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RusAlex/d89b4e325f29bc0b3371 to your computer and use it in GitHub Desktop.
Save RusAlex/d89b4e325f29bc0b3371 to your computer and use it in GitHub Desktop.
<?php
namespace tests\codeception\unit\models;
/**
*
* CREATE table user (
* id int unsigned primary key auto_increment,
* test bit(1) NOT NULL
* ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
*/
use Yii;
use yii\codeception\DbTestCase;
use app\tests\codeception\fixtures\MyFixture;
use yii\db\Connection;
use app\models\MyModel;
class MyTest extends DbTestCase
{
public function fixtures()
{
return [
'items' => MyFixture::className()
];
}
public function testFirst()
{
$connection = Yii::$app->db->createCommand("
INSERT INTO `user` (`id`, `test`) VALUES
(1, b'0'),
(2, b'1');
")->execute();
$r = MyModel::find()->asArray()->all();
echo '<pre>'; var_dump($r); echo '</pre>'; die();
/**
* OUTPUT:
* <pre>array(2) {
* [0]=>
* array(2) {
* ["id"]=>
* string(1) "1"
* ["test"]=>
* string(1) "0"
* }
* [1]=>
* array(2) {
* ["id"]=>
* string(1) "2"
* ["test"]=>
* string(1) "1"
* }
*}
*</pre>
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment