Created
July 23, 2015 17:30
-
-
Save RusAlex/d89b4e325f29bc0b3371 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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