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
4fb73ae6
Commit
4fb73ae6
authored
Mar 01, 2011
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
! Fixed issue #36
parent
350ca36f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
30 deletions
+75
-30
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture.php
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture.php
+61
-1
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture/Eav/Abstract.php
...ity/EcomDev/PHPUnit/Model/Mysql4/Fixture/Eav/Abstract.php
+0
-25
app/code/community/EcomDev/PHPUnit/Test/Suite.php
app/code/community/EcomDev/PHPUnit/Test/Suite.php
+10
-2
app/code/community/EcomDev/PHPUnit/etc/config.xml
app/code/community/EcomDev/PHPUnit/etc/config.xml
+2
-0
lib/EcomDev/Utils/Reflection.php
lib/EcomDev/Utils/Reflection.php
+2
-2
No files found.
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture.php
View file @
4fb73ae6
...
@@ -50,11 +50,71 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
...
@@ -50,11 +50,71 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
*/
*/
public
function
loadTableData
(
$tableEntity
,
$tableData
)
public
function
loadTableData
(
$tableEntity
,
$tableData
)
{
{
$tableColumns
=
$this
->
_getWriteAdapter
()
->
describeTable
(
$this
->
getTable
(
$tableEntity
));
$records
=
array
();
foreach
(
$tableData
as
$row
)
{
$records
[]
=
$this
->
_getTableRecord
(
$row
,
$tableColumns
);
}
$this
->
_getWriteAdapter
()
->
insertMultiple
(
$this
->
_getWriteAdapter
()
->
insertMultiple
(
$this
->
getTable
(
$tableEntity
),
$this
->
getTable
(
$tableEntity
),
$
tableData
$
records
);
);
return
$this
;
return
$this
;
}
}
/**
* Prepares entity table record from array
*
* @param array $row
* @param array $tableColumns list of entity_table columns
* @return array
*/
protected
function
_getTableRecord
(
$row
,
$tableColumns
)
{
$record
=
array
();
// Fullfil table records with data
foreach
(
$tableColumns
as
$columnName
=>
$definition
)
{
if
(
isset
(
$row
[
$columnName
]))
{
$record
[
$columnName
]
=
$this
->
_getTableRecordValue
(
$row
[
$columnName
]);
}
elseif
(
$definition
[
'DEFAULT'
]
!==
null
)
{
$record
[
$columnName
]
=
$definition
[
'DEFAULT'
];
}
else
{
$record
[
$columnName
]
=
((
$definition
[
'NULLABLE'
])
?
null
:
''
);
}
}
return
$record
;
}
/**
* Processes table record values,
* used for transforming custom values like serialized
* or JSON data
*
*
* @param mixed $value
* @return string
*/
protected
function
_getTableRecordValue
(
$value
)
{
// If it is scalar php type, then just return itself
if
(
!
is_array
(
$value
))
{
return
$value
;
}
if
(
isset
(
$value
[
'json'
]))
{
return
Mage
::
helper
(
'core'
)
->
jsonEncode
(
$value
[
'json'
]);
}
if
(
isset
(
$value
[
'serialized'
]))
{
return
serialize
(
$value
[
'serialized'
]);
}
throw
new
InvalidArgumentException
(
'Unrecognized type for DB column'
);
}
}
}
\ No newline at end of file
app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture/Eav/Abstract.php
View file @
4fb73ae6
...
@@ -266,31 +266,6 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev
...
@@ -266,31 +266,6 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev
}
}
/**
* Prepares entity table record from array
*
* @param array $row
* @param array $tableColumns list of entity_table columns
* @return array
*/
protected
function
_getTableRecord
(
$row
,
$tableColumns
)
{
$record
=
array
();
// Fullfil table records with data
foreach
(
$tableColumns
as
$columnName
=>
$definition
)
{
if
(
isset
(
$row
[
$columnName
]))
{
$record
[
$columnName
]
=
$row
[
$columnName
];
}
elseif
(
$definition
[
'DEFAULT'
]
!==
null
)
{
$record
[
$columnName
]
=
$definition
[
'DEFAULT'
];
}
else
{
$record
[
$columnName
]
=
((
$definition
[
'NULLABLE'
])
?
null
:
''
);
}
}
return
$record
;
}
/**
/**
* Retrieves attribute records for single entity
* Retrieves attribute records for single entity
*
*
...
...
app/code/community/EcomDev/PHPUnit/Test/Suite.php
View file @
4fb73ae6
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
*/
/**
/**
* Test suite for Magento
* Test suite for Magento
*
*
...
@@ -29,6 +30,7 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
...
@@ -29,6 +30,7 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
const
XML_PATH_UNIT_TEST_GROUPS
=
'phpunit/suite/groups'
;
const
XML_PATH_UNIT_TEST_GROUPS
=
'phpunit/suite/groups'
;
const
XML_PATH_UNIT_TEST_MODULES
=
'phpunit/suite/modules'
;
const
XML_PATH_UNIT_TEST_MODULES
=
'phpunit/suite/modules'
;
const
XML_PATH_UNIT_TEST_APP
=
'phpunit/suite/app'
;
const
XML_PATH_UNIT_TEST_APP
=
'phpunit/suite/app'
;
const
XML_PATH_UNIT_TEST_SUITE
=
'phpunit/suite/test_suite'
;
const
CACHE_TAG
=
'ECOMDEV_PHPUNIT'
;
const
CACHE_TAG
=
'ECOMDEV_PHPUNIT'
;
const
CACHE_TYPE
=
'ecomdev_phpunit'
;
const
CACHE_TYPE
=
'ecomdev_phpunit'
;
...
@@ -71,7 +73,14 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
...
@@ -71,7 +73,14 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
{
{
$groups
=
Mage
::
getConfig
()
->
getNode
(
self
::
XML_PATH_UNIT_TEST_GROUPS
);
$groups
=
Mage
::
getConfig
()
->
getNode
(
self
::
XML_PATH_UNIT_TEST_GROUPS
);
$modules
=
Mage
::
getConfig
()
->
getNode
(
self
::
XML_PATH_UNIT_TEST_MODULES
);
$modules
=
Mage
::
getConfig
()
->
getNode
(
self
::
XML_PATH_UNIT_TEST_MODULES
);
$testSuiteClass
=
EcomDev_Utils_Reflection
::
getRelflection
((
string
)
Mage
::
getConfig
()
->
getNode
(
self
::
XML_PATH_UNIT_TEST_SUITE
));
if
(
!
$testSuiteClass
->
isSubclassOf
(
'EcomDev_PHPUnit_Test_Suite_Group'
))
{
new
RuntimeException
(
'Test Suite class should be extended from EcomDev_PHPUnit_Test_Suite_Group'
);
}
$suite
=
new
self
(
'Magento Test Suite'
);
$suite
=
new
self
(
'Magento Test Suite'
);
// Walk through different groups in modules for finding test cases
// Walk through different groups in modules for finding test cases
foreach
(
$groups
->
children
()
as
$group
)
{
foreach
(
$groups
->
children
()
as
$group
)
{
foreach
(
$modules
->
children
()
as
$module
)
{
foreach
(
$modules
->
children
()
as
$module
)
{
...
@@ -96,8 +105,7 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
...
@@ -96,8 +105,7 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
$testCases
=
self
::
_loadTestCases
(
$searchPath
,
$moduleCodeDir
);
$testCases
=
self
::
_loadTestCases
(
$searchPath
,
$moduleCodeDir
);
foreach
(
$testCases
as
$className
)
{
foreach
(
$testCases
as
$className
)
{
$classReflection
=
EcomDev_Utils_Reflection
::
getRelflection
(
$className
);
$suite
->
addTest
(
$testSuiteClass
->
newInstance
(
$className
,
$currentGroups
));
$suite
->
addTest
(
new
PHPUnit_Framework_TestSuite
(
$classReflection
),
$currentGroups
);
}
}
}
}
}
}
...
...
app/code/community/EcomDev/PHPUnit/etc/config.xml
View file @
4fb73ae6
...
@@ -51,6 +51,8 @@
...
@@ -51,6 +51,8 @@
<helpers>
Helper
</helpers>
<helpers>
Helper
</helpers>
<blocks>
Block
</blocks>
<blocks>
Block
</blocks>
</groups>
</groups>
<!-- Test suite that will be used for creation of each of the tests -->
<test_suite>
EcomDev_PHPUnit_Test_Suite_Group
</test_suite>
<fixture>
<fixture>
<eav>
<eav>
<!-- Here goes the list of fixture loaders for EAV
<!-- Here goes the list of fixture loaders for EAV
...
...
lib/EcomDev/Utils/Reflection.php
View file @
4fb73ae6
...
@@ -67,7 +67,7 @@ class EcomDev_Utils_Reflection
...
@@ -67,7 +67,7 @@ class EcomDev_Utils_Reflection
$reflectionMethod
->
setAccessible
(
true
);
$reflectionMethod
->
setAccessible
(
true
);
if
(
!
empty
(
$args
))
{
if
(
!
empty
(
$args
))
{
return
$reflectionMethod
->
invokeArgs
(
$reflectionObject
,
$args
);
return
$reflectionMethod
->
invokeArgs
(
(
is_string
(
$object
)
?
null
:
$object
)
,
$args
);
}
}
return
$reflectionMethod
->
invoke
((
is_string
(
$object
)
?
null
:
$object
));
return
$reflectionMethod
->
invoke
((
is_string
(
$object
)
?
null
:
$object
));
...
@@ -96,7 +96,7 @@ class EcomDev_Utils_Reflection
...
@@ -96,7 +96,7 @@ class EcomDev_Utils_Reflection
if
(
isset
(
self
::
$_reflectionCache
[
$objectHash
]))
{
if
(
isset
(
self
::
$_reflectionCache
[
$objectHash
]))
{
return
self
::
$_reflectionCache
[
$objectHash
];
return
self
::
$_reflectionCache
[
$objectHash
];
}
}
$reflection
=
new
Reflection
Class
(
$object
);
$reflection
=
new
Reflection
Object
(
$object
);
self
::
$_reflectionCache
[
$objectHash
]
=
$reflection
;
self
::
$_reflectionCache
[
$objectHash
]
=
$reflection
;
return
$reflection
;
return
$reflection
;
}
}
...
...
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