Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
8abeed03
Commit
8abeed03
authored
Sep 06, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added SchemaTest
parent
544e412a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
1 deletion
+111
-1
Schema.php
framework/yii/db/cubrid/Schema.php
+1
-1
SchemaTest.php
tests/unit/framework/db/SchemaTest.php
+70
-0
CubridSchemaTest.php
tests/unit/framework/db/cubrid/CubridSchemaTest.php
+31
-0
SqliteSchemaTest.php
tests/unit/framework/db/sqlite/SqliteSchemaTest.php
+9
-0
No files found.
framework/yii/db/cubrid/Schema.php
View file @
8abeed03
...
...
@@ -227,7 +227,7 @@ class Schema extends \yii\db\Schema
$tableNames
=
array
();
foreach
(
$tables
as
$table
)
{
// do not list system tables
if
(
$table
[
'TYPE'
]
!=
=
0
)
{
if
(
$table
[
'TYPE'
]
!=
0
)
{
$tableNames
[]
=
$table
[
'NAME'
];
}
}
...
...
tests/unit/framework/db/SchemaTest.php
0 → 100644
View file @
8abeed03
<?php
namespace
yiiunit\framework\db
;
use
yii\caching\FileCache
;
use
yii\db\Schema
;
class
SchemaTest
extends
DatabaseTestCase
{
public
function
testGetPDOType
()
{
$values
=
array
(
array
(
null
,
\PDO
::
PARAM_NULL
),
array
(
''
,
\PDO
::
PARAM_STR
),
array
(
'hello'
,
\PDO
::
PARAM_STR
),
array
(
0
,
\PDO
::
PARAM_INT
),
array
(
1
,
\PDO
::
PARAM_INT
),
array
(
1337
,
\PDO
::
PARAM_INT
),
array
(
true
,
\PDO
::
PARAM_BOOL
),
array
(
false
,
\PDO
::
PARAM_BOOL
),
array
(
$fp
=
fopen
(
__FILE__
,
'rb'
),
\PDO
::
PARAM_LOB
),
);
$schema
=
$this
->
getConnection
()
->
schema
;
foreach
(
$values
as
$value
)
{
$this
->
assertEquals
(
$value
[
1
],
$schema
->
getPdoType
(
$value
[
0
]));
}
fclose
(
$fp
);
}
public
function
testFindTableNames
()
{
/** @var Schema $schema */
$schema
=
$this
->
getConnection
()
->
schema
;
$tables
=
$schema
->
getTableNames
();
$this
->
assertTrue
(
in_array
(
'tbl_customer'
,
$tables
));
$this
->
assertTrue
(
in_array
(
'tbl_category'
,
$tables
));
$this
->
assertTrue
(
in_array
(
'tbl_item'
,
$tables
));
$this
->
assertTrue
(
in_array
(
'tbl_order'
,
$tables
));
$this
->
assertTrue
(
in_array
(
'tbl_order_item'
,
$tables
));
$this
->
assertTrue
(
in_array
(
'tbl_type'
,
$tables
));
}
public
function
testGetTableSchemas
()
{
/** @var Schema $schema */
$schema
=
$this
->
getConnection
()
->
schema
;
$tables
=
$schema
->
getTableSchemas
();
$this
->
assertEquals
(
count
(
$schema
->
getTableNames
()),
count
(
$tables
));
foreach
(
$tables
as
$table
)
{
$this
->
assertInstanceOf
(
'yii\db\TableSchema'
,
$table
);
}
}
public
function
testSchemaCache
()
{
/** @var Schema $schema */
$schema
=
$this
->
getConnection
()
->
schema
;
$schema
->
db
->
enableSchemaCache
=
true
;
$schema
->
db
->
schemaCache
=
new
FileCache
();
$noCacheTable
=
$schema
->
getTableSchema
(
'tbl_type'
,
true
);
$cachedTable
=
$schema
->
getTableSchema
(
'tbl_type'
,
true
);
$this
->
assertEquals
(
$noCacheTable
,
$cachedTable
);
}
}
tests/unit/framework/db/cubrid/CubridSchemaTest.php
0 → 100644
View file @
8abeed03
<?php
namespace
yiiunit\framework\db\cubrid
;
use
yiiunit\framework\db\SchemaTest
;
class
CubridSchemaTest
extends
SchemaTest
{
public
$driverName
=
'cubrid'
;
public
function
testGetPDOType
()
{
$values
=
array
(
null
=>
\PDO
::
PARAM_NULL
,
''
=>
\PDO
::
PARAM_STR
,
'hello'
=>
\PDO
::
PARAM_STR
,
0
=>
\PDO
::
PARAM_INT
,
1
=>
\PDO
::
PARAM_INT
,
1337
=>
\PDO
::
PARAM_INT
,
true
=>
\PDO
::
PARAM_INT
,
// CUBRID PDO does not support PARAM_BOOL
false
=>
\PDO
::
PARAM_INT
,
// CUBRID PDO does not support PARAM_BOOL
);
$schema
=
$this
->
getConnection
()
->
schema
;
foreach
(
$values
as
$value
=>
$type
)
{
$this
->
assertEquals
(
$type
,
$schema
->
getPdoType
(
$value
));
}
$this
->
assertEquals
(
\PDO
::
PARAM_LOB
,
$schema
->
getPdoType
(
$fp
=
fopen
(
__FILE__
,
'rb'
)));
fclose
(
$fp
);
}
}
tests/unit/framework/db/sqlite/SqliteSchemaTest.php
0 → 100644
View file @
8abeed03
<?php
namespace
yiiunit\framework\db\sqlite
;
use
yiiunit\framework\db\SchemaTest
;
class
SqliteSchemaTest
extends
SchemaTest
{
protected
$driverName
=
'sqlite'
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment