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
b0fd8e25
Commit
b0fd8e25
authored
Feb 17, 2012
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
! Compatibility and strict issues fixed for extension
parent
be294b5a
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
67 additions
and
46 deletions
+67
-46
app/code/community/EcomDev/PHPUnit/Model/Config.php
app/code/community/EcomDev/PHPUnit/Model/Config.php
+12
-0
app/code/community/EcomDev/PHPUnit/Model/Fixture.php
app/code/community/EcomDev/PHPUnit/Model/Fixture.php
+13
-25
app/code/community/EcomDev/PHPUnit/Model/Layout.php
app/code/community/EcomDev/PHPUnit/Model/Layout.php
+9
-4
app/code/community/EcomDev/PHPUnit/Test/Case.php
app/code/community/EcomDev/PHPUnit/Test/Case.php
+1
-1
app/code/community/EcomDev/PHPUnit/Test/Case/Config.php
app/code/community/EcomDev/PHPUnit/Test/Case/Config.php
+1
-1
app/code/community/EcomDev/PHPUnit/Test/Case/Controller.php
app/code/community/EcomDev/PHPUnit/Test/Case/Controller.php
+3
-3
lib/EcomDev/PHPUnit/Constraint/Config.php
lib/EcomDev/PHPUnit/Constraint/Config.php
+2
-2
lib/EcomDev/PHPUnit/Constraint/Config/Resource/Script.php
lib/EcomDev/PHPUnit/Constraint/Config/Resource/Script.php
+4
-2
lib/EcomDev/PHPUnit/Constraint/Config/TableAlias.php
lib/EcomDev/PHPUnit/Constraint/Config/TableAlias.php
+2
-2
lib/EcomDev/PHPUnit/Constraint/Controller/Response/Body.php
lib/EcomDev/PHPUnit/Constraint/Controller/Response/Body.php
+16
-2
lib/EcomDev/PHPUnit/Constraint/Controller/Response/Header.php
...EcomDev/PHPUnit/Constraint/Controller/Response/Header.php
+1
-1
lib/EcomDev/PHPUnit/Constraint/Layout/Abstract.php
lib/EcomDev/PHPUnit/Constraint/Layout/Abstract.php
+1
-1
lib/EcomDev/PHPUnit/Constraint/Layout/Block.php
lib/EcomDev/PHPUnit/Constraint/Layout/Block.php
+1
-1
lib/EcomDev/PHPUnit/Constraint/Layout/Block/Action.php
lib/EcomDev/PHPUnit/Constraint/Layout/Block/Action.php
+1
-1
No files found.
app/code/community/EcomDev/PHPUnit/Model/Config.php
View file @
b0fd8e25
...
...
@@ -64,6 +64,18 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
return
$this
;
}
/**
* Get events configuration
*
* @param string $area event area
* @param string $eventName event name
* @return Mage_Core_Model_Config_Element
*/
public
function
getEventConfig
(
$area
,
$eventName
)
{
return
$this
->
getNode
(
$area
)
->
events
->
{
$eventName
};
}
/**
* Replaces creation of some instance by mock object
*
...
...
app/code/community/EcomDev/PHPUnit/Model/Fixture.php
View file @
b0fd8e25
...
...
@@ -502,6 +502,18 @@ class EcomDev_PHPUnit_Model_Fixture
}
Mage
::
getConfig
()
->
loadDb
();
// Flush website and store configuration caches
foreach
(
Mage
::
app
()
->
getWebsites
(
true
)
as
$website
)
{
EcomDev_Utils_Reflection
::
setRestrictedPropertyValue
(
$website
,
'_configCache'
,
array
()
);
}
foreach
(
Mage
::
app
()
->
getStores
(
true
)
as
$store
)
{
EcomDev_Utils_Reflection
::
setRestrictedPropertyValue
(
$store
,
'_configCache'
,
array
()
);
}
return
$this
;
}
...
...
@@ -653,31 +665,7 @@ class EcomDev_PHPUnit_Model_Fixture
*/
protected
function
_setConfigNodeValue
(
$path
,
$value
)
{
$pathArray
=
explode
(
'/'
,
$path
);
$scope
=
array_shift
(
$pathArray
);
switch
(
$scope
)
{
case
'stores'
:
$storeCode
=
array_shift
(
$pathArray
);
Mage
::
app
()
->
getStore
(
$storeCode
)
->
setConfig
(
implode
(
'/'
,
$pathArray
),
$value
);
break
;
case
'websites'
:
$websiteCode
=
array_shift
(
$pathArray
);
$website
=
Mage
::
app
()
->
getWebsite
(
$websiteCode
);
EcomDev_Utils_Reflection
::
setRestrictedPropertyValue
(
$website
,
'_configCache'
,
array
()
);
// Should change value
default
:
Mage
::
getConfig
()
->
setNode
(
$path
,
$value
);
break
;
}
return
$this
;
}
...
...
app/code/community/EcomDev/PHPUnit/Model/Layout.php
View file @
b0fd8e25
...
...
@@ -112,9 +112,10 @@ class EcomDev_PHPUnit_Model_Layout
$this
->
_records
=
array
();
foreach
(
$this
->
_blocks
as
$block
)
{
/* @var $block Mage_Core_Block_Abstract */
// Remove references between blocks
$block
->
setParentBlock
(
null
);
$block
->
setMessageBlock
(
null
);
EcomDev_Utils_Reflection
::
setRestrictedPropertyValue
(
$block
,
'_parentBlock'
,
null
);
$block
->
unsMessageBlock
(
);
$block
->
unsetChildren
();
}
...
...
@@ -285,9 +286,9 @@ class EcomDev_PHPUnit_Model_Layout
protected
function
_generateAction
(
$node
,
$parent
)
{
$this
->
_collectedArgs
=
$this
->
_collectActionArguments
(
$node
);
$this
->
_translateLayoutNode
(
$node
,
$this
->
_collectedArgs
);
parent
::
_generateAction
(
$node
,
$parent
);
if
(
$this
->
_collectedArgs
!==
null
)
{
$this
->
_translateLayoutNode
(
$node
,
$this
->
_collectedArgs
);
$method
=
(
string
)
$node
[
'method'
];
if
(
!
empty
(
$node
[
'block'
]))
{
$parentName
=
(
string
)
$node
[
'block'
];
...
...
@@ -307,10 +308,14 @@ class EcomDev_PHPUnit_Model_Layout
* Collects action arguments
*
* @param Varien_SimpleXml_Element $node
* @return array
* @return array
|null
*/
protected
function
_collectActionArguments
(
$node
)
{
if
(
isset
(
$node
[
'ifconfig'
])
&&
!
Mage
::
getStoreConfigFlag
((
string
)
$node
[
'ifconfig'
]))
{
return
null
;
}
$args
=
(
array
)
$node
->
children
();
unset
(
$args
[
'@attributes'
]);
...
...
app/code/community/EcomDev/PHPUnit/Test/Case.php
View file @
b0fd8e25
...
...
@@ -718,7 +718,7 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
if
(
current
(
$annotationValue
))
{
$classAlias
=
current
(
$annotationValue
);
}
else
{
$classAlias
=
self
::
app
()
->
getConfig
()
->
getNode
(
$configPath
);
$classAlias
=
(
string
)
self
::
app
()
->
getConfig
()
->
getNode
(
$configPath
);
}
return
$classAlias
;
...
...
app/code/community/EcomDev/PHPUnit/Test/Case/Config.php
View file @
b0fd8e25
...
...
@@ -186,7 +186,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
* @param EcomDev_PHPUnit_Constraint_Config $constraint
* @param string $message
*/
public
static
function
assertThatConfig
(
EcomDev_PHPUnit_Constraint_Config
$constraint
,
$message
)
public
static
function
assertThatConfig
(
PHPUnit_Framework_Constraint
$constraint
,
$message
)
{
self
::
assertThat
(
Mage
::
getConfig
(),
$constraint
,
$message
);
}
...
...
app/code/community/EcomDev/PHPUnit/Test/Case/Controller.php
View file @
b0fd8e25
...
...
@@ -80,7 +80,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* @param string $type
* @return EcomDev_PHPUnit_Constraint_Layout
*/
public
static
function
layout
(
$type
=
EcomDev_PHPUnit_Constraint_Layout
::
TYPE_LOADED
)
public
static
function
layout
(
$type
)
{
return
new
EcomDev_PHPUnit_Constraint_Layout
(
$type
);
}
...
...
@@ -437,10 +437,10 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
/**
* Assert shortcut for response assertions
*
* @param EcomDev_PHPUnit_Constraint_Controller_Response_
Header
$constraint
* @param EcomDev_PHPUnit_Constraint_Controller_Response_
Abstract
$constraint
* @param string $message
*/
public
static
function
assertThatResponse
(
EcomDev_PHPUnit_Constraint_Controller_Response_Header
$constraint
,
$message
)
public
static
function
assertThatResponse
(
PHPUnit_Framework_Constraint
$constraint
,
$message
)
{
self
::
assertThat
(
self
::
getResponse
(),
$constraint
,
$message
);
}
...
...
lib/EcomDev/PHPUnit/Constraint/Config.php
View file @
b0fd8e25
...
...
@@ -58,11 +58,11 @@ class EcomDev_PHPUnit_Constraint_Config extends PHPUnit_Framework_Constraint
* @param string $description
* @param boolean $not
*/
public
function
fail
(
$other
,
$description
,
$not
)
public
function
fail
(
$other
,
$description
,
PHPUnit_Framework_ComparisonFailure
$comparisonFailure
=
NULL
)
{
$nodeValue
=
$this
->
getNodeValue
(
$other
);
return
$this
->
constraint
->
fail
(
$nodeValue
,
$description
,
$
not
);
return
$this
->
constraint
->
fail
(
$nodeValue
,
$description
,
$
comparisonFailure
);
}
/**
...
...
lib/EcomDev/PHPUnit/Constraint/Config/Resource/Script.php
View file @
b0fd8e25
...
...
@@ -120,9 +120,11 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
}
// Sort install scripts by version
usort
(
$result
[
'install'
],
array
(
$this
,
'compareVersions'
));
usort
(
$result
[
'scheme'
][
'install'
],
array
(
$this
,
'compareVersions'
));
usort
(
$result
[
'data'
][
'install'
],
array
(
$this
,
'compareVersions'
));
// Sort upgrade scripts by version
usort
(
$result
[
'upgrade'
],
array
(
$this
,
'compareVersions'
));
usort
(
$result
[
'scheme'
][
'upgrade'
],
array
(
$this
,
'compareVersions'
));
usort
(
$result
[
'data'
][
'upgrade'
],
array
(
$this
,
'compareVersions'
));
return
$result
;
}
...
...
lib/EcomDev/PHPUnit/Constraint/Config/TableAlias.php
View file @
b0fd8e25
...
...
@@ -59,7 +59,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias
protected
function
evaluateTableAlias
(
$other
)
{
if
(
!
isset
(
$other
->
{
$this
->
_tableAliasPrefix
}))
{
$this
->
setActualValue
(
false
);
$this
->
setActualValue
(
''
);
return
false
;
}
...
...
@@ -72,7 +72,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias
if
(
isset
(
$modelNode
->
entities
->
{
$this
->
_tableAliasName
}
->
table
))
{
$tableName
=
(
string
)
$modelNode
->
entities
->
{
$this
->
_tableAliasName
}
->
table
;
}
else
{
$tableName
=
false
;
$tableName
=
''
;
}
$this
->
setActualValue
(
$tableName
);
...
...
lib/EcomDev/PHPUnit/Constraint/Controller/Response/Body.php
View file @
b0fd8e25
...
...
@@ -49,7 +49,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Body
protected
function
evaluateConstraint
(
$other
)
{
$this
->
setActualValue
(
$other
->
getOutputBody
());
return
$this
->
_expectedValue
->
evaluate
(
$this
->
_actualValue
);
return
$this
->
_expectedValue
->
evaluate
(
$this
->
_actualValue
,
''
,
true
);
}
/**
...
...
@@ -59,6 +59,20 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Body
*/
protected
function
textConstraint
()
{
return
sprintf
(
'body %s'
,
$this
->
_expectedValue
->
toString
());
return
$this
->
_expectedValue
->
toString
();
}
/**
* Custom failure description
*
* @param $other
* @return string
*/
protected
function
customFailureDescription
(
$other
)
{
return
sprintf
(
'request body %s.'
,
$this
->
toString
()
);
}
}
\ No newline at end of file
lib/EcomDev/PHPUnit/Constraint/Controller/Response/Header.php
View file @
b0fd8e25
...
...
@@ -85,7 +85,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Header
protected
function
evaluateConstraint
(
$other
)
{
$this
->
setActualValue
(
$other
->
getSentHeader
(
$this
->
_headerName
));
return
$this
->
_expectedValue
->
evaluate
(
$this
->
_actualValue
);
return
$this
->
_expectedValue
->
evaluate
(
$this
->
_actualValue
,
''
,
true
);
}
/**
...
...
lib/EcomDev/PHPUnit/Constraint/Layout/Abstract.php
View file @
b0fd8e25
...
...
@@ -40,7 +40,7 @@ abstract class EcomDev_PHPUnit_Constraint_Layout_Abstract extends EcomDev_PHPUni
* (non-PHPdoc)
* @see EcomDev_PHPUnit_Constraint_Abstract::getActualValue()
*/
protected
function
getActualValue
(
$other
)
protected
function
getActualValue
(
$other
=
null
)
{
if
(
$this
->
_useActualValue
)
{
return
parent
::
getActualValue
(
$other
);
...
...
lib/EcomDev/PHPUnit/Constraint/Layout/Block.php
View file @
b0fd8e25
...
...
@@ -133,7 +133,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block extends EcomDev_PHPUnit_Constraint
}
$this
->
setActualValue
(
$renderInfo
[
'content'
]);
return
$this
->
_expectedValue
->
evaluate
(
$renderInfo
[
'content'
]);
return
$this
->
_expectedValue
->
evaluate
(
$renderInfo
[
'content'
]
,
''
,
true
);
}
/**
...
...
lib/EcomDev/PHPUnit/Constraint/Layout/Block/Action.php
View file @
b0fd8e25
...
...
@@ -150,7 +150,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block_Action extends EcomDev_PHPUnit_Con
$withArguments
=
' with expected arguments'
;
}
return
sprintf
(
'block "%s" action for method "%s"
wa
s invoked%s'
,
return
sprintf
(
'block "%s" action for method "%s"
i
s invoked%s'
,
$this
->
_blockName
,
$this
->
_method
,
$withArguments
);
}
...
...
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