Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EcomDev_PHPUnit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Open
EcomDev_PHPUnit
Commits
c8821f04
Commit
c8821f04
authored
Oct 26, 2013
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor unit tests for db info retrieval
parent
02690886
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
198 additions
and
169 deletions
+198
-169
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Db/Info.php
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Db/Info.php
+15
-12
app/code/community/EcomDev/PHPUnitTest/Test/Model/Mysql4/Db/InfoTest.php
...ity/EcomDev/PHPUnitTest/Test/Model/Mysql4/Db/InfoTest.php
+85
-157
app/code/community/EcomDev/PHPUnitTest/Test/Model/Mysql4/Db/_data/dp-tableStructure.yaml
...nitTest/Test/Model/Mysql4/Db/_data/dp-tableStructure.yaml
+65
-0
app/code/community/EcomDev/PHPUnitTest/Test/Model/Mysql4/Db/_data/ex-fetchData.yaml
.../PHPUnitTest/Test/Model/Mysql4/Db/_data/ex-fetchData.yaml
+33
-0
No files found.
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Db/Info.php
View file @
c8821f04
...
...
@@ -8,7 +8,6 @@ class EcomDev_PHPUnit_Model_Mysql4_Db_Info implements EcomDev_PHPUnit_Model_Mysq
/** @var array Information about the magento database [table => [...]]. */
protected
$_information
;
/**
* Before fetching information about a table.
*
...
...
@@ -22,25 +21,30 @@ class EcomDev_PHPUnit_Model_Mysql4_Db_Info implements EcomDev_PHPUnit_Model_Mysq
// iterate over each available table
$listTables
=
$this
->
getAdapter
()
->
listTables
();
foreach
(
$listTables
as
$tableName
)
{
foreach
(
$listTables
as
$tableName
)
{
// describe the table
$data
=
new
Varien_Object
();
$data
->
setData
(
$this
->
getAdapter
()
->
describeTable
(
$tableName
));
$columns
=
array
();
foreach
(
$this
->
getAdapter
()
->
describeTable
(
$tableName
)
as
$column
=>
$info
)
{
$columns
[
$column
][
'type'
]
=
$info
[
'DATA_TYPE'
];
$columns
[
$column
][
'length'
]
=
$info
[
'LENGTH'
];
$columns
[
$column
][
'unsigned'
]
=
(
bool
)
$info
[
'UNSIGNED'
];
$columns
[
$column
][
'primary'
]
=
(
bool
)
$info
[
'PRIMARY'
];
$columns
[
$column
][
'default'
]
=
$info
[
'DEFAULT'
];
}
$data
->
setColumns
(
$columns
);
$foreignKeys
=
$this
->
getAdapter
()
->
getForeignKeys
(
$tableName
);
$dependency
=
array
();
if
(
is_array
(
$foreignKeys
))
{
if
(
is_array
(
$foreignKeys
))
{
// add each depending table
foreach
(
$foreignKeys
as
$keyData
)
{
foreach
(
$foreignKeys
as
$keyData
)
{
$dependency
[]
=
$keyData
[
'REF_TABLE_NAME'
];
}
}
$data
->
setDependencies
(
$dependency
);
$this
->
_information
[
$tableName
]
=
$data
;
}
...
...
@@ -102,9 +106,8 @@ class EcomDev_PHPUnit_Model_Mysql4_Db_Info implements EcomDev_PHPUnit_Model_Mysq
*/
public
function
setAdapter
(
$adapter
)
{
if
(
!
(
$adapter
instanceof
Zend_Db_Adapter_Abstract
))
{
throw
new
InvalidArgumentException
(
'Unsupported adapter '
.
get_class
(
$adapter
));
if
(
!
(
$adapter
instanceof
Zend_Db_Adapter_Abstract
))
{
throw
new
InvalidArgumentException
(
'Adapter should be an instance of Zend_Db_Adapter_Abstract'
);
}
$this
->
_adapter
=
$adapter
;
...
...
app/code/community/EcomDev/PHPUnitTest/Test/Model/Mysql4/Db/InfoTest.php
View file @
c8821f04
This diff is collapsed.
Click to expand it.
app/code/community/EcomDev/PHPUnitTest/Test/Model/Mysql4/Db/_data/dp-tableStructure.yaml
0 → 100644
View file @
c8821f04
-
-
child
:
columns
:
child_id
:
SCHEMA_NAME
:
test
TABLE_NAME
:
child
COLUMN_NAME
:
child_id
COLUMN_POSITION
:
0
DATA_TYPE
:
int
DEFAULT
:
'
'
LENGTH
:
10
UNSIGNED
:
true
PRIMARY
:
true
PRIMARY_POSITION
:
0
IDENTITY
:
true
parent_id
:
SCHEMA_NAME
:
test
TABLE_NAME
:
child
COLUMN_NAME
:
parent_id
COLUMN_POSITION
:
0
DATA_TYPE
:
int
DEFAULT
:
'
'
LENGTH
:
10
UNSIGNED
:
true
PRIMARY
:
false
PRIMARY_POSITION
:
0
IDENTITY
:
false
foreign_keys
:
fk_mother
:
FK_NAME
:
fk_mother
SCHEMA_NAME
:
test
TABLE_NAME
:
child
COLUMN_NAME
:
parent_id
REF_SHEMA_NAME
:
test
REF_TABLE_NAME
:
mother
REF_COLUMN_NAME
:
mother_id
ON_DELETE
:
'
'
ON_UPDATE
:
'
'
mother
:
columns
:
mother_id
:
SCHEMA_NAME
:
test
TABLE_NAME
:
mother
COLUMN_NAME
:
mother_id
COLUMN_POSITION
:
0
DATA_TYPE
:
int
DEFAULT
:
'
'
LENGTH
:
10
UNSIGNED
:
true
PRIMARY
:
true
PRIMARY_POSITION
:
0
IDENTITY
:
true
name
:
SCHEMA_NAME
:
test
TABLE_NAME
:
mother
COLUMN_NAME
:
name
COLUMN_POSITION
:
0
DATA_TYPE
:
varchar
DEFAULT
:
'
'
LENGTH
:
255
UNSIGNED
:
false
PRIMARY
:
false
PRIMARY_POSITION
:
0
IDENTITY
:
false
foreign_keys
:
[
]
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Model/Mysql4/Db/_data/ex-fetchData.yaml
0 → 100644
View file @
c8821f04
tables
:
mother
:
columns
:
mother_id
:
type
:
int
length
:
10
unsigned
:
true
primary
:
true
default
:
'
'
name
:
type
:
varchar
length
:
255
unsigned
:
false
primary
:
false
default
:
'
'
dependencies
:
[]
child
:
columns
:
child_id
:
type
:
int
length
:
10
unsigned
:
true
primary
:
true
default
:
'
'
parent_id
:
type
:
int
length
:
10
unsigned
:
true
primary
:
false
default
:
'
'
dependencies
:
-
mother
\ No newline at end of file
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