From 0b71a3e9b3abaa669550cf216ab440fae71d6ca8 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Sun, 11 Dec 2016 12:46:43 +0100 Subject: [PATCH] fix tests configuration --- .gitignore | 2 + codeception.yml | 5 ++ .../m000000_000001_create_user_table.php | 3 +- tests/_data/schema.sql | 79 +++++++++++++++++++ tests/functional.suite.yml | 6 +- 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 tests/_data/schema.sql diff --git a/.gitignore b/.gitignore index 8171ada..025caf2 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ Vagrantfile # javascript files /node_modules +tests/_support/_generated +tests/_output/* diff --git a/codeception.yml b/codeception.yml index 7f8b0b0..350d801 100644 --- a/codeception.yml +++ b/codeception.yml @@ -10,6 +10,11 @@ settings: memory_limit: 1024M modules: config: + Db: + dsn: 'mysql:host=localhost;dbname=test' + user: 'root' + password: + dump: tests/_data/schema.sql Yii2: configFile: 'tests/_app/config/test.php' coverage: diff --git a/lib/User/resources/migrations/m000000_000001_create_user_table.php b/lib/User/resources/migrations/m000000_000001_create_user_table.php index a7f192c..3e1fd66 100644 --- a/lib/User/resources/migrations/m000000_000001_create_user_table.php +++ b/lib/User/resources/migrations/m000000_000001_create_user_table.php @@ -12,7 +12,8 @@ class m000000_000001_create_user_table extends \yii\db\Migration 'password_hash' => $this->string(60)->notNull(), 'auth_key' => $this->string(32)->notNull(), 'unconfirmed_email' => $this->string(255), - 'registration_id' => $this->string(45), + 'registration_ip' => $this->string(45), + 'flags' => $this->integer()->notNull()->defaultValue('0'), 'confirmed_at' => $this->integer(), 'blocked_at' => $this->integer(), 'updated_at' => $this->integer()->notNull(), diff --git a/tests/_data/schema.sql b/tests/_data/schema.sql new file mode 100644 index 0000000..489a8fb --- /dev/null +++ b/tests/_data/schema.sql @@ -0,0 +1,79 @@ +SET NAMES utf8; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for `profile` +-- ---------------------------- +DROP TABLE IF EXISTS `profile`; +CREATE TABLE `profile` ( + `user_id` int(11) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `public_email` varchar(255) DEFAULT NULL, + `gravatar_email` varchar(255) DEFAULT NULL, + `gravatar_id` varchar(32) DEFAULT NULL, + `location` varchar(255) DEFAULT NULL, + `website` varchar(255) DEFAULT NULL, + `timezone` varchar(40) DEFAULT NULL, + `bio` text, + PRIMARY KEY (`user_id`), + CONSTRAINT `fk_user_profile` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for `social_account` +-- ---------------------------- +DROP TABLE IF EXISTS `social_account`; +CREATE TABLE `social_account` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) DEFAULT NULL, + `provider` varchar(255) NOT NULL, + `client_id` varchar(255) NOT NULL, + `code` varchar(32) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `username` varchar(255) DEFAULT NULL, + `data` text, + `created_at` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `account_unique` (`provider`,`client_id`), + UNIQUE KEY `account_unique_code` (`code`), + KEY `fk_user_account` (`user_id`), + CONSTRAINT `fk_user_account` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for `token` +-- ---------------------------- +DROP TABLE IF EXISTS `token`; +CREATE TABLE `token` ( + `user_id` int(11) NOT NULL, + `code` varchar(32) NOT NULL, + `type` smallint(6) NOT NULL, + `created_at` int(11) NOT NULL, + UNIQUE KEY `token_unique` (`user_id`,`code`,`type`), + CONSTRAINT `fk_user_token` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for `user` +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) NOT NULL, + `email` varchar(255) NOT NULL, + `password_hash` varchar(60) NOT NULL, + `auth_key` varchar(32) NOT NULL, + `unconfirmed_email` varchar(255) DEFAULT NULL, + `registration_ip` varchar(45) DEFAULT NULL, + `confirmed_at` int(11) DEFAULT NULL, + `blocked_at` int(11) DEFAULT NULL, + `created_at` int(11) NOT NULL, + `updated_at` int(11) NOT NULL, + `flags` int(11) NOT NULL DEFAULT '0', + + PRIMARY KEY (`id`), + UNIQUE KEY `user_unique_email` (`email`), + UNIQUE KEY `user_unique_username` (`username`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/tests/functional.suite.yml b/tests/functional.suite.yml index c4dccda..455237e 100644 --- a/tests/functional.suite.yml +++ b/tests/functional.suite.yml @@ -3,4 +3,8 @@ modules: enabled: - Filesystem - Yii2 - - Asserts \ No newline at end of file + - Asserts + - Db: + populate: true + cleanup: true + reconnect: false