File tree Expand file tree Collapse file tree 6 files changed +88
-3
lines changed Expand file tree Collapse file tree 6 files changed +88
-3
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,13 @@ settings:
9
9
colors : true
10
10
suite_class : \PHPUnit_Framework_TestSuite
11
11
memory_limit : 1024M
12
- log : true
12
+ log : true
13
+ modules :
14
+ config :
15
+ Db :
16
+ dsn : ' mysql:host=localhost;dbname=wschat_tests'
17
+ # dsn: 'pgsql:host=localhost;dbname=wschat_tests'
18
+ user : ' '
19
+ password : ' '
20
+ dump : codeception/_data/pgsql.sql
21
+ # dump: codeception/_data/mysql.sql
Original file line number Diff line number Diff line change
1
+ DROP TABLE IF EXISTS history;
2
+
3
+ CREATE TABLE history (
4
+ id UNSIGNED INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5
+ chat_id VARCHAR (60 ),
6
+ chat_title VARCHAR (60 ),
7
+ user_id VARCHAR (60 ),
8
+ username VARCHAR (60 ),
9
+ avatar_16 VARCHAR (90 ),
10
+ avatar_32 VARCHAR (90 ),
11
+ timestamp UNSIGNED INTEGER NOT NULL DEFAULT 0 ,
12
+ message TEXT
13
+ );
Original file line number Diff line number Diff line change
1
+ DROP TABLE IF EXISTS history CASCADE;
2
+
3
+ CREATE TABLE history (
4
+ id SERIAL ,
5
+ chat_id CHARACTER VARYING (60 ),
6
+ chat_name CHARACTER VARYING (60 ),
7
+ user_id CHARACTER VARYING (60 ),
8
+ username CHARACTER VARYING (60 ),
9
+ avatar_16 CHARACTER VARYING (90 ),
10
+ avatar_32 CHARACTER VARYING (90 ),
11
+ timestamp INTEGER NOT NULL ,
12
+ message TEXT
13
+ );
14
+
15
+ ALTER TABLE history ADD PRIMARY KEY (id);
Original file line number Diff line number Diff line change 9
9
'mongodb ' => [
10
10
'class ' => '\yii\mongodb\Connection ' ,
11
11
'dsn ' => 'mongodb://localhost:27017/wschat-tests '
12
- ]
12
+ ],
13
+ 'db ' => [
14
+ 'class ' => 'yii\db\Connection ' ,
15
+ 'dsn ' => 'pgsql:host=localhost;dbname=wschat_tests ' ,
16
+ // 'dsn' => 'mysql:host=localhost;dbname=wschat_tests',
17
+ 'username ' => '' ,
18
+ 'password ' => '' ,
19
+ 'charset ' => 'utf8 ' ,
20
+ ],
13
21
],
14
22
];
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace tests \codeception \unit ;
3
+
4
+ use yii \codeception \TestCase ;
5
+ use jones \wschat \components \AbstractStorage ;
6
+
7
+ class PgsqlStorageTest extends TestCase
8
+ {
9
+ protected $ params = [
10
+ 'chat_id ' => 1 ,
11
+ 'chat_title ' => 'Pgsql chat room ' ,
12
+ 'user_id ' => 1 ,
13
+ 'username ' => 'Pgsql user ' ,
14
+ 'avatar_16 ' => null ,
15
+ 'avatar_32 ' => null ,
16
+ 'message ' => 'Simple text message ' ,
17
+ 'timestamp ' => 0
18
+ ];
19
+
20
+ /**
21
+ * @covers \jones\wschat\components\DbStorage::storeMessage
22
+ */
23
+ public function testStoreMessage ()
24
+ {
25
+ AbstractStorage::factory ('pgsql ' )->storeMessage ($ this ->params );
26
+ }
27
+
28
+ /**
29
+ * @depends testStoreMessage
30
+ * @covers \jones\wschat\components\DbStorage::getHistory
31
+ */
32
+ public function testGetHistory ()
33
+ {
34
+ $ data = AbstractStorage::factory ('pgsql ' )->getHistory ($ this ->params ['chat_id ' ]);
35
+ $ this ->assertNotEmpty ($ data );
36
+ $ this ->assertEquals (1 , sizeof ($ data ), 'Only one message should be in history table ' );
37
+ $ this ->assertEquals ($ this ->params ['message ' ], $ data [0 ]['message ' ]);
38
+ }
39
+
40
+ }
Original file line number Diff line number Diff line change 1
- <?php //[STAMP] fdf172ba8533e948a77c75f941094bf8
1
+ <?php //[STAMP] 28423caeac2888a162c4d002b6d0c560
2
2
3
3
// This class was automatically generated by build task
4
4
// You should not change it manually as it will be overwritten on next build
You can’t perform that action at this time.
0 commit comments