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
20b9f742
Commit
20b9f742
authored
Jan 17, 2013
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/fix-constraints' into dev
parents
07d89667
051a6efd
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
853 additions
and
51 deletions
+853
-51
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Abstract.php
...nity/EcomDev/PHPUnitTest/Test/Lib/Constraint/Abstract.php
+77
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node.php
...y/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node.php
+78
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node/providers/testConstructorAccepts.yaml
...straint/Config/Node/providers/testConstructorAccepts.yaml
+18
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node/providers/testEqualsXml.yaml
...t/Lib/Constraint/Config/Node/providers/testEqualsXml.yaml
+43
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node/providers/testEqualsXmlFailure.yaml
...onstraint/Config/Node/providers/testEqualsXmlFailure.yaml
+30
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/Script.php
...HPUnitTest/Test/Lib/Constraint/Config/Resource/Script.php
+84
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/expectations/testGetVersionScriptsDiff.yaml
...nfig/Resource/expectations/testGetVersionScriptsDiff.yaml
+64
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/expectations/testParseVersions.yaml
...raint/Config/Resource/expectations/testParseVersions.yaml
+200
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/fixtures/files.yaml
...t/Test/Lib/Constraint/Config/Resource/fixtures/files.yaml
+44
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/providers/testGetVersionScriptsDiff.yaml
.../Config/Resource/providers/testGetVersionScriptsDiff.yaml
+40
-0
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/providers/testParseVersions.yaml
...nstraint/Config/Resource/providers/testParseVersions.yaml
+16
-0
app/code/community/EcomDev/PHPUnitTest/etc/config.xml
app/code/community/EcomDev/PHPUnitTest/etc/config.xml
+13
-0
app/etc/modules/EcomDev_PHPUnitTest.xml
app/etc/modules/EcomDev_PHPUnitTest.xml
+27
-0
lib/EcomDev/PHPUnit/Constraint/Abstract.php
lib/EcomDev/PHPUnit/Constraint/Abstract.php
+68
-12
lib/EcomDev/PHPUnit/Constraint/Config/Abstract.php
lib/EcomDev/PHPUnit/Constraint/Config/Abstract.php
+21
-2
lib/EcomDev/PHPUnit/Constraint/Config/Layout.php
lib/EcomDev/PHPUnit/Constraint/Config/Layout.php
+15
-6
lib/EcomDev/PHPUnit/Constraint/Config/Module.php
lib/EcomDev/PHPUnit/Constraint/Config/Module.php
+1
-3
lib/EcomDev/PHPUnit/Constraint/Config/Node.php
lib/EcomDev/PHPUnit/Constraint/Config/Node.php
+6
-23
lib/EcomDev/PHPUnit/Constraint/Config/Resource/Script.php
lib/EcomDev/PHPUnit/Constraint/Config/Resource/Script.php
+5
-1
modman
modman
+3
-4
No files found.
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Abstract.php
0 → 100644
View file @
20b9f742
<?php
class
EcomDev_PHPUnitTest_Test_Lib_Constraint_Abstract
extends
PHPUnit_Framework_TestCase
{
/**
* Test compare values functionality for constraint
*
* @param mixed $expectedValue
* @param mixed $actualValue
* @param bool $expectedResult
*
* @dataProvider dataProviderForCompareValues
*/
public
function
testCompareValues
(
$expectedValue
,
$actualValue
,
$expectedResult
)
{
/**
* @var $constraint EcomDev_PHPUnit_Constraint_Abstract
*/
$constraint
=
$this
->
getMockForAbstractClass
(
'EcomDev_PHPUnit_Constraint_Abstract'
,
array
(),
''
,
false
);
$this
->
assertSame
(
$expectedResult
,
$constraint
->
compareValues
(
$expectedValue
,
$actualValue
)
);
if
(
!
$expectedResult
)
{
$this
->
assertAttributeInstanceOf
(
'PHPUnit_Framework_ComparisonFailure'
,
'_comparisonFailure'
,
$constraint
);
}
}
/**
* Data provider for checking compare values functionality
*
* @return array
*/
public
function
dataProviderForCompareValues
()
{
return
array
(
array
(
array
(
'value1'
,
'value2'
,
'value3'
),
array
(
'value1'
,
'value2'
,
'value3'
),
true
),
array
(
array
(
'value1'
,
'value2'
,
'value3'
),
array
(
'value1'
,
'value1'
,
'value3'
),
false
),
array
(
array
(
'value1'
,
0
,
'value3'
),
array
(
'value1'
,
'value1'
,
'value3'
),
false
),
array
(
'1'
,
1
,
true
),
array
(
'0'
,
0
,
true
),
array
(
'1'
,
0
,
false
),
array
(
''
,
0
,
false
)
);
}
}
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node.php
0 → 100644
View file @
20b9f742
<?php
class
EcomDev_PHPUnitTest_Test_Lib_Constraint_Config_Node
extends
EcomDev_PHPUnit_Test_Case
{
/**
* Creates constraint instance
*
* @param $nodePath
* @param $type
* @param $value
*
* @return EcomDev_PHPUnit_Constraint_Config_Node
*/
protected
function
_getConstraint
(
$nodePath
,
$type
,
$value
)
{
return
new
EcomDev_PHPUnit_Constraint_Config_Node
(
$nodePath
,
$type
,
$value
);
}
/**
* Test constructor of the node,
*
* @param mixed $expectedValue
* @param string $type
*
* @dataProvider dataProvider
*/
public
function
testConstructorAccepts
(
$expectedValue
,
$type
)
{
$constraint
=
$this
->
_getConstraint
(
'some/dummy/path'
,
$type
,
$expectedValue
);
$this
->
assertAttributeEquals
(
$expectedValue
,
'_expectedValue'
,
$constraint
);
}
/**
* Tests that particular value equals xml
*
* @param string $actualValue
* @param string $expectedValue
* @dataProvider dataProvider
*/
public
function
testEqualsXml
(
$actualValue
,
$expectedValue
)
{
$actualValue
=
new
SimpleXMLElement
(
$actualValue
);
$expectedValue
=
new
SimpleXMLElement
(
$expectedValue
);
$constraint
=
$this
->
_getConstraint
(
'some/dummy/path'
,
EcomDev_PHPUnit_Constraint_Config_Node
::
TYPE_EQUALS_XML
,
$expectedValue
);
$this
->
assertTrue
(
$constraint
->
evaluate
(
$actualValue
,
''
,
true
));
$this
->
assertAttributeEmpty
(
'_comparisonFailure'
,
$constraint
);
}
/**
* Tests that particular value equals xml
*
* @param string $actualValue
* @param string $expectedValue
* @dataProvider dataProvider
*/
public
function
testEqualsXmlFailure
(
$actualValue
,
$expectedValue
)
{
$actualValue
=
new
SimpleXMLElement
(
$actualValue
);
$expectedValue
=
new
SimpleXMLElement
(
$expectedValue
);
$constraint
=
$this
->
_getConstraint
(
'some/dummy/path'
,
EcomDev_PHPUnit_Constraint_Config_Node
::
TYPE_EQUALS_XML
,
$expectedValue
);
$this
->
assertFalse
(
$constraint
->
evaluate
(
$actualValue
,
''
,
true
));
$this
->
assertAttributeNotEmpty
(
'_comparisonFailure'
,
$constraint
);
$this
->
assertAttributeInstanceOf
(
'PHPUnit_Framework_ComparisonFailure'
,
'_comparisonFailure'
,
$constraint
);
}
}
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node/providers/testConstructorAccepts.yaml
0 → 100644
View file @
20b9f742
-
-
1
-
equals_string
-
-
'
0'
-
equals_string
-
-
0.01
-
equals_string
-
-
"
0.01"
-
equals_decimal
-
-
"
0"
-
equals_decimal
-
-
"
100.0123"
-
equals_decimal
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node/providers/testEqualsXml.yaml
0 → 100644
View file @
20b9f742
-
actual
:
|
<config>
<value>1</value>
<value>2</value>
</config>
expected
:
|
<config>
<value>1</value>
<value>2</value>
</config>
-
actual
:
|
<config>
<value>1</value>
<value>2</value>
</config>
expected
:
|
<config>
<value>1</value>
<value>2</value>
</config>
-
actual
:
|
<config>
<value>1</value>
<value>2</value>
<more_nested><value>1</value><value>2</value></more_nested>
</config>
expected
:
|
<config>
<value>1</value>
<value>2</value>
<more_nested>
<value>1</value>
<value>2</value>
</more_nested>
</config>
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Node/providers/testEqualsXmlFailure.yaml
0 → 100644
View file @
20b9f742
-
actual
:
|
<config>
<value>1</value>
<value>2</value>
</config>
expected
:
|
<config>
<value>2</value>
<value>3</value>
</config>
-
actual
:
|
<config>
<value>1</value>
<value>2</value>
<more_nested>
<value>1</value>
<value>2</value>
</more_nested>
</config>
expected
:
|
<config>
<value>1</value>
<value>2</value>
<more_nested>
<value>1</value>
<value>1</value>
</more_nested>
</config>
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/Script.php
0 → 100644
View file @
20b9f742
<?php
/**
* A test case for testing script assertions
*
* @loadSharedFixture files
*/
class
EcomDev_PHPUnitTest_Test_Lib_Constraint_Config_Resource_Script
extends
EcomDev_PHPUnit_Test_Case
{
/**
* @var EcomDev_PHPUnit_Constraint_Config_Resource_Script
*/
protected
$constraint
=
null
;
protected
function
setUp
()
{
$this
->
constraint
=
$this
->
getMockBuilder
(
'EcomDev_PHPUnit_Constraint_Config_Resource_Script'
)
->
disableOriginalConstructor
()
->
setMethods
(
null
)
->
getMock
();
}
/**
* Returns path within vfs stream
*
* @param string[]|string $directories
* @return string[]|string
*/
protected
function
getVirtualPath
(
$directories
)
{
if
(
!
is_array
(
$directories
))
{
$directories
=
array
(
$directories
);
}
$virtualPath
=
array
();
foreach
(
$directories
as
$directory
)
{
$virtualPath
[]
=
$this
->
getFixture
()
->
getVfs
()
->
url
(
$directory
);
}
if
(
count
(
$virtualPath
)
===
1
)
{
$virtualPath
=
current
(
$virtualPath
);
}
return
$virtualPath
;
}
/**
*
* @param $directory
* @dataProvider dataProvider
*/
public
function
testParseVersions
(
$directories
)
{
$virtualPath
=
$this
->
getVirtualPath
(
$directories
);
$result
=
EcomDev_Utils_Reflection
::
invokeRestrictedMethod
(
$this
->
constraint
,
'parseVersions'
,
array
(
$virtualPath
));
$this
->
assertEquals
(
$this
->
expected
(
'auto'
)
->
getVersions
(),
$result
);
}
/**
* Test version
*
* @param string[]|string $directories
* @param string $type
* @param string $from
* @param string $to
*
* @return void
* @dataProvider dataProvider
*/
public
function
testGetVersionScriptsDiff
(
$directories
,
$type
,
$from
,
$to
)
{
$virtualPath
=
$this
->
getVirtualPath
(
$directories
);
$versions
=
EcomDev_Utils_Reflection
::
invokeRestrictedMethod
(
$this
->
constraint
,
'parseVersions'
,
array
(
$virtualPath
));
$result
=
EcomDev_Utils_Reflection
::
invokeRestrictedMethod
(
$this
->
constraint
,
'getVersionScriptsDiff'
,
array
(
$versions
[
$type
],
$from
,
$to
,
$type
===
'data'
?
'data-'
:
''
));
$this
->
assertEquals
(
$this
->
expected
(
'auto'
)
->
getDiff
(),
$result
);
}
}
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/expectations/testGetVersionScriptsDiff.yaml
0 → 100644
View file @
20b9f742
from_1.0.0_to_1.0.1_one
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
actual
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
from_1.0.0_to_1.0.5_one
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
-
upgrade-1.0.1-1.0.5.php
actual
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
to_1.0.5_one
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
-
upgrade-1.0.1-1.0.5.php
actual
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
from_1.0.0_one
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
actual
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
from_1.0.0_to_1.0.1_one_invalid
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
actual
:
-
upgrade-1.0.0-1.0.1.php
from_1.0.0_to_1.0.5_one_invalid
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
-
upgrade-1.0.1-1.0.5.php
actual
:
-
upgrade-1.0.0-1.0.1.php
from_1.0.0_one_invalid
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
actual
:
-
upgrade-1.0.0-1.0.1.php
to_1.0.5_one_invalid
:
diff
:
expected
:
-
install-1.0.0.php
-
upgrade-1.0.0-1.0.1.php
-
upgrade-1.0.1-1.0.5.php
actual
:
-
upgrade-1.0.0-1.0.1.php
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/expectations/testParseVersions.yaml
0 → 100644
View file @
20b9f742
directory_one_valid
:
versions
:
scheme
:
install
:
-
filename
:
install-1.0.0.php
prefix
:
install
from
:
1.0.0
to
:
null
-
filename
:
mysql4-install-0.8.0.php
prefix
:
mysql4-install
from
:
0.8.0
to
:
null
upgrade
:
-
filename
:
upgrade-1.0.0-1.0.1.php
prefix
:
upgrade
from
:
1.0.0
to
:
1.0.1
-
filename
:
mysql4-upgrade-0.8.0-0.8.1.php
prefix
:
mysql4-upgrade
from
:
0.8.0
to
:
0.8.1
data
:
install
:
[]
upgrade
:
[]
directory_two_valid
:
versions
:
scheme
:
install
:
-
filename
:
install-1.0.0.php
prefix
:
install
from
:
1.0.0
to
:
null
-
filename
:
mysql4-install-0.8.0.php
prefix
:
mysql4-install
from
:
0.8.0
to
:
null
upgrade
:
-
filename
:
upgrade-1.0.0-1.0.1.php
prefix
:
upgrade
from
:
1.0.0
to
:
1.0.1
-
filename
:
upgrade-1.0.1-1.0.2.php
prefix
:
upgrade
from
:
1.0.1
to
:
1.0.2
-
filename
:
upgrade-1.0.2-1.0.3.php
prefix
:
upgrade
from
:
1.0.2
to
:
1.0.3
-
filename
:
upgrade-1.0.3-1.0.4.php
prefix
:
upgrade
from
:
1.0.3
to
:
1.0.4
-
filename
:
mysql4-upgrade-0.8.0-0.8.1.php
prefix
:
mysql4-upgrade
from
:
0.8.0
to
:
0.8.1
-
filename
:
mysql4-upgrade-0.8.1-0.8.2.php
prefix
:
mysql4-upgrade
from
:
0.8.1
to
:
0.8.2
-
filename
:
mysql4-upgrade-0.8.2-0.8.3.php
prefix
:
mysql4-upgrade
from
:
0.8.2
to
:
0.8.3
-
filename
:
mysql4-upgrade-0.8.3-0.8.4.php
prefix
:
mysql4-upgrade
from
:
0.8.3
to
:
0.8.4
data
:
install
:
[]
upgrade
:
[]
directory_one_data_scheme_valid
:
versions
:
scheme
:
install
:
-
filename
:
install-1.0.0.php
prefix
:
install
from
:
1.0.0
to
:
null
upgrade
:
-
filename
:
upgrade-1.0.0-1.0.1.php
prefix
:
upgrade
from
:
1.0.0
to
:
1.0.1
-
filename
:
upgrade-1.0.1-1.0.2.php
prefix
:
upgrade
from
:
1.0.1
to
:
1.0.2
-
filename
:
upgrade-1.0.2-1.0.3.php
prefix
:
upgrade
from
:
1.0.2
to
:
1.0.3
-
filename
:
upgrade-1.0.3-1.0.4.php
prefix
:
upgrade
from
:
1.0.3
to
:
1.0.4
data
:
install
:
-
filename
:
data-install-1.0.0.php
prefix
:
data-install
from
:
1.0.0
to
:
null
upgrade
:
-
filename
:
data-upgrade-1.0.0-1.0.1.php
prefix
:
data-upgrade
from
:
1.0.0
to
:
1.0.1
-
filename
:
data-upgrade-1.0.1-1.0.2.php
prefix
:
data-upgrade
from
:
1.0.1
to
:
1.0.2
-
filename
:
data-upgrade-1.0.2-1.0.3.php
prefix
:
data-upgrade
from
:
1.0.2
to
:
1.0.3
-
filename
:
data-upgrade-1.0.3-1.0.4.php
prefix
:
data-upgrade
from
:
1.0.3
to
:
1.0.4
directory_one_invalid
:
versions
:
scheme
:
install
:
[]
upgrade
:
-
filename
:
upgrade-1.0.0-1.0.1.php
prefix
:
upgrade
from
:
1.0.0
to
:
1.0.1
data
:
install
:
[]
upgrade
:
[]
directory_two_invalid
:
versions
:
scheme
:
install
:
-
filename
:
install-1.0.0.php
prefix
:
install
from
:
1.0.0
to
:
null
upgrade
:
-
filename
:
upgrade-1.0.1-1.0.2.php
prefix
:
upgrade
from
:
1.0.1
to
:
1.0.2
-
filename
:
upgrade-1.0.2-1.0.3.php
prefix
:
upgrade
from
:
1.0.2
to
:
1.0.3
-
filename
:
upgrade-1.0.3-1.0.4.php
prefix
:
upgrade
from
:
1.0.3
to
:
1.0.4
data
:
install
:
[]
upgrade
:
[]
directory_one_data_scheme_invalid
:
versions
:
scheme
:
install
:
-
filename
:
install-1.0.0.php
prefix
:
install
from
:
1.0.0
to
:
null
upgrade
:
-
filename
:
upgrade-1.0.0-1.0.1.php
prefix
:
upgrade
from
:
1.0.0
to
:
1.0.1
-
filename
:
upgrade-1.0.1-1.0.2.php
prefix
:
upgrade
from
:
1.0.1
to
:
1.0.2
-
filename
:
upgrade-1.0.2-1.0.3.php
prefix
:
upgrade
from
:
1.0.2
to
:
1.0.3
-
filename
:
upgrade-1.0.3-1.0.4.php
prefix
:
upgrade
from
:
1.0.3
to
:
1.0.4
data
:
install
:
-
filename
:
data-install-1.0.0.php
prefix
:
data-install
from
:
1.0.0
to
:
null
upgrade
:
-
filename
:
data-upgrade-1.0.1-1.0.2.php
prefix
:
data-upgrade
from
:
1.0.1
to
:
1.0.2
-
filename
:
data-upgrade-1.0.2-1.0.3.php
prefix
:
data-upgrade
from
:
1.0.2
to
:
1.0.3
-
filename
:
data-upgrade-1.0.3-1.0.4.php
prefix
:
data-upgrade
from
:
1.0.3
to
:
1.0.4
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/fixtures/files.yaml
0 → 100644
View file @
20b9f742
vfs
:
directory_one_valid
:
install-1.0.0.php
:
<?php // file
upgrade-1.0.0-1.0.1.php
:
<?php // file
mysql4-install-0.8.0.php
:
<?php // file
mysql4-upgrade-0.8.0-0.8.1.php
:
<?php // file
directory_two_valid
:
install-1.0.0.php
:
<?php // file
upgrade-1.0.0-1.0.1.php
:
<?php // file
upgrade-1.0.1-1.0.2.php
:
<?php // file
upgrade-1.0.2-1.0.3.php
:
<?php // file
upgrade-1.0.3-1.0.4.php
:
<?php // file
mysql4-install-0.8.0.php
:
<?php // file
mysql4-upgrade-0.8.0-0.8.1.php
:
<?php // file
mysql4-upgrade-0.8.1-0.8.2.php
:
<?php // file
mysql4-upgrade-0.8.2-0.8.3.php
:
<?php // file
mysql4-upgrade-0.8.3-0.8.4.php
:
<?php // file
directory_one_data_valid
:
data-install-1.0.0.php
:
<?php // file
data-upgrade-1.0.0-1.0.1.php
:
<?php // file
data-upgrade-1.0.1-1.0.2.php
:
<?php // file
data-upgrade-1.0.2-1.0.3.php
:
<?php // file
data-upgrade-1.0.3-1.0.4.php
:
<?php // file
directory_one_scheme_valid
:
install-1.0.0.php
:
<?php // file
upgrade-1.0.0-1.0.1.php
:
<?php // file
upgrade-1.0.1-1.0.2.php
:
<?php // file
upgrade-1.0.2-1.0.3.php
:
<?php // file
upgrade-1.0.3-1.0.4.php
:
<?php // file
directory_one_invalid
:
instal-1.0.0.php
:
<?php // file
# error in install script file name
upgrade-1.0.0-1.0.1.php
:
<?php // file
directory_two_invalid
:
install-1.0.0.php
:
<?php // file
update-1.0.0-1.0.1.php
:
<?php // file
# error in upgrade script file name
upgrade-1.0.1-1.0.2.php
:
<?php // file
upgrade-1.0.2-1.0.3.php
:
<?php // file
upgrade-1.0.3-1.0.4.php
:
<?php // file
directory_one_data_invalid
:
data-install-1.0.0.php
:
<?php // file
data-upgade-1.0.0-1.0.1.php
:
<?php // file
# error in the filename
data-upgrade-1.0.1-1.0.2.php
:
<?php // file
data-upgrade-1.0.2-1.0.3.php
:
<?php // file
data-upgrade-1.0.3-1.0.4.php
:
<?php // file
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/providers/testGetVersionScriptsDiff.yaml
0 → 100644
View file @
20b9f742
from_1.0.0_to_1.0.1_one
:
-
directory_one_valid
-
scheme
-
1.0.0
-
1.0.1
from_1.0.0_to_1.0.5_one
:
-
directory_one_valid
-
scheme
-
1.0.0
-
1.0.5
to_1.0.5_one
:
-
directory_one_valid
-
scheme
-
null
-
1.0.5
from_1.0.0_one
:
-
directory_one_valid
-
scheme
-
1.0.0
-
null
from_1.0.0_to_1.0.1_one_invalid
:
-
directory_one_invalid
-
scheme
-
1.0.0
-
1.0.1
from_1.0.0_to_1.0.5_one_invalid
:
-
directory_one_invalid
-
scheme
-
1.0.0
-
1.0.5
from_1.0.0_one_invalid
:
-
directory_one_invalid
-
scheme
-
1.0.0
-
null
to_1.0.5_one_invalid
:
-
directory_one_invalid
-
scheme
-
null
-
1.0.5
app/code/community/EcomDev/PHPUnitTest/Test/Lib/Constraint/Config/Resource/providers/testParseVersions.yaml
0 → 100644
View file @
20b9f742
directory_one_valid
:
-
directory_one_valid
directory_two_valid
:
-
directory_two_valid
directory_one_data_scheme_valid
:
-
-
directory_one_data_valid
-
directory_one_scheme_valid
directory_one_invalid
:
-
directory_one_invalid
directory_two_invalid
:
-
directory_two_invalid
directory_one_data_scheme_invalid
:
-
-
directory_one_data_invalid
-
directory_one_scheme_valid
\ No newline at end of file
app/code/community/EcomDev/PHPUnitTest/etc/config.xml
0 → 100644
View file @
20b9f742
<config>
<phpunit>
<suite>
<modules>
<EcomDev_PHPUnitTest
/>
</modules>
<groups>
<lib>
Lib
</lib>
</groups>
</suite>
</phpunit>
</config>
\ No newline at end of file
app/etc/modules/EcomDev_PHPUnitTest.xml
0 → 100644
View file @
20b9f742
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
-->
<config>
<modules>
<EcomDev_PHPUnitTest>
<codePool>
community
</codePool>
<active>
true
</active>
</EcomDev_PHPUnitTest>
</modules>
</config>
\ No newline at end of file
lib/EcomDev/PHPUnit/Constraint/Abstract.php
View file @
20b9f742
...
...
@@ -20,7 +20,6 @@
* Abstract constraint for EcomDev_PHPUnit constraints
* Contains flexible constaint types implementation
*
* @todo refactor failures for being 100% compatible with PHPUnit 3.6
*/
abstract
class
EcomDev_PHPUnit_Constraint_Abstract
extends
PHPUnit_Framework_Constraint
...
...
@@ -74,12 +73,21 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
*/
protected
$_useActualValue
=
false
;
/**
* Comparison failure for nice failure messages
*
* @var PHPUnit_Framework_ComparisonFailure
*/
protected
$_comparisonFailure
=
null
;
/**
* Abstract cnstraint constructor,
* provides unified interface for working with multiple types of evalation
*
* @param string $type
* @param mixed $expectedValue
* @param mixed $expectedValue
*
* @throws PHPUnit_Framework_Exception
*/
public
function
__construct
(
$type
,
$expectedValue
=
null
)
{
...
...
@@ -98,7 +106,7 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
if
(
isset
(
$this
->
_expectedValueValidation
[
$type
]))
{
$expectedValueType
=
(
isset
(
$this
->
_expectedValueValidation
[
$type
][
2
])
?
isset
(
$this
->
_expectedValueValidation
[
$type
][
2
])
:
$this
->
_expectedValueValidation
[
$type
][
2
]
:
''
);
// Mandatory check
...
...
@@ -186,17 +194,9 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
$failureDescription
=
sprintf
(
'Failed asserting that %s'
,
$this
->
failureDescription
(
$other
));
if
(
in_array
(
$this
->
_type
,
$this
->
_typesWithDiff
))
{
$actual
=
$this
->
getActualValue
(
$other
);
$expected
=
$this
->
getExpectedValue
();
throw
new
EcomDev_PHPUnit_Constraint_Exception
(
$failureDescription
,
new
PHPUnit_Framework_ComparisonFailure
(
$expected
,
$actual
,
$this
->
exportAsString
(
$expected
),
$this
->
exportAsString
(
$actual
)
),
$this
->
getComparisonFailure
(
$this
->
getExpectedValue
(),
$this
->
getActualValue
(
$other
)),
$description
);
}
else
{
...
...
@@ -278,4 +278,60 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
return
PHPUnit_Util_Type
::
export
(
$value
);
}
}
/**
* Compares two values by using correct comparator for two types
*
* @param mixed $expectedValue
* @param mixed $actualValue
* @return bool
*/
public
function
compareValues
(
$expectedValue
,
$actualValue
)
{
$comparatorFactory
=
PHPUnit_Framework_ComparatorFactory
::
getDefaultInstance
();
try
{
$comparator
=
$comparatorFactory
->
getComparatorFor
(
$expectedValue
,
$actualValue
);
$comparator
->
assertEquals
(
$expectedValue
,
$actualValue
);
}
catch
(
PHPUnit_Framework_ComparisonFailure
$f
)
{
$this
->
_comparisonFailure
=
$f
;
return
false
;
}
return
true
;
}
/**
* Retrieve comparison failure exception.
*
* Is used for generation of the failure messages
*
* @param mixed $actualValue
* @param mixed $expectedValue
*
* @return PHPUnit_Framework_ComparisonFailure
*/
public
function
getComparisonFailure
(
$actualValue
,
$expectedValue
)
{
if
(
$this
->
_comparisonFailure
!==
null
)
{
$failure
=
$this
->
_comparisonFailure
;
$this
->
_comparisonFailure
=
null
;
return
$failure
;
}
return
new
PHPUnit_Framework_ComparisonFailure
(
$expectedValue
,
$actualValue
,
$this
->
exportAsString
(
$expectedValue
),
$this
->
exportAsString
(
$actualValue
)
);
}
}
lib/EcomDev/PHPUnit/Constraint/Config/Abstract.php
View file @
20b9f742
...
...
@@ -86,7 +86,7 @@ abstract class EcomDev_PHPUnit_Constraint_Config_Abstract
protected
function
getActualValue
(
$other
=
null
)
{
if
(
!
$this
->
_useActualValue
&&
$other
->
hasChildren
())
{
return
$
other
->
asNiceXml
(
);
return
$
this
->
getXmlAsDom
(
$this
->
_expectedValue
);
}
elseif
(
!
$this
->
_useActualValue
)
{
return
(
string
)
$other
;
}
...
...
@@ -102,9 +102,28 @@ abstract class EcomDev_PHPUnit_Constraint_Config_Abstract
protected
function
getExpectedValue
()
{
if
(
$this
->
_expectedValue
instanceof
Varien_Simplexml_Element
)
{
return
$this
->
_expectedValue
->
asNiceXml
(
);
return
$this
->
getXmlAsDom
(
$this
->
_expectedValue
);
}
return
parent
::
getExpectedValue
();
}
/**
* Converts xml to dom object
*
* @param $xmlValue
* @return DOMDocument
*/
protected
function
getXmlAsDom
(
$xmlValue
)
{
if
(
$xmlValue
instanceof
SimpleXMLElement
)
{
$xmlValue
=
$xmlValue
->
asXML
();
}
$domValue
=
new
DOMDocument
;
$domValue
->
preserveWhiteSpace
=
FALSE
;
$domValue
->
loadXML
(
$xmlValue
);
return
$domValue
;
}
}
\ No newline at end of file
lib/EcomDev/PHPUnit/Constraint/Config/Layout.php
View file @
20b9f742
...
...
@@ -90,6 +90,7 @@ class EcomDev_PHPUnit_Constraint_Config_Layout
);
$this
->
_typesWithDiff
[]
=
self
::
TYPE_LAYOUT_FILE
;
$this
->
_typesWithDiff
[]
=
self
::
TYPE_LAYOUT_DEFINITION
;
$nodePath
=
sprintf
(
self
::
XML_PATH_LAYOUT
,
$area
);
...
...
@@ -131,7 +132,18 @@ class EcomDev_PHPUnit_Constraint_Config_Layout
}
}
return
false
;
if
(
$this
->
_layoutUpdate
===
null
)
{
$this
->
_layoutUpdate
=
'your_module'
;
}
$expected
=
clone
$other
;
$expected
->
addChild
(
$this
->
_layoutUpdate
)
->
addChild
(
'file'
,
htmlspecialchars
(
$this
->
_expectedValue
));
return
$this
->
compareValues
(
$this
->
getXmlAsDom
(
$expected
),
$this
->
getXmlAsDom
(
$other
)
);
}
/**
...
...
@@ -156,15 +168,12 @@ class EcomDev_PHPUnit_Constraint_Config_Layout
* @param Varien_Simplexml_Element $other
* @return boolean
*/
protected
function
evaluateLayoutFile
(
$other
)
protected
function
evaluateLayoutFile
()
{
$assertion
=
self
::
getDesignPackageModel
()
->
getLayoutFileAssertion
(
$this
->
_expectedValue
,
$this
->
_area
,
$this
->
_designPackage
,
$this
->
_theme
);
$this
->
setActualValue
(
$assertion
[
'actual'
]);
$this
->
_expectedValue
=
$assertion
[
'expected'
];
return
$this
->
_actualValue
===
$this
->
_expectedValue
;
return
$this
->
compareValues
(
$assertion
[
'expected'
],
$assertion
[
'actual'
]);
}
/**
...
...
lib/EcomDev/PHPUnit/Constraint/Config/Module.php
View file @
20b9f742
...
...
@@ -99,9 +99,7 @@ class EcomDev_PHPUnit_Constraint_Config_Module
*/
protected
function
evaluateCodePool
(
$other
)
{
$this
->
setActualValue
((
string
)
$other
->
codePool
);
return
$this
->
_actualValue
===
$this
->
_expectedValue
;
return
$this
->
compareValues
(
$this
->
_expectedValue
,
(
string
)
$other
->
codePool
);
}
/**
...
...
lib/EcomDev/PHPUnit/Constraint/Config/Node.php
View file @
20b9f742
...
...
@@ -43,7 +43,7 @@ class EcomDev_PHPUnit_Constraint_Config_Node
public
function
__construct
(
$nodePath
,
$type
,
$expectedValue
=
null
)
{
$this
->
_expectedValueValidation
+=
array
(
self
::
TYPE_EQUALS_STRING
=>
array
(
true
,
'is_s
tring'
,
'string
'
),
self
::
TYPE_EQUALS_STRING
=>
array
(
true
,
'is_s
calar'
,
'scalar
'
),
self
::
TYPE_EQUALS_NUMBER
=>
array
(
true
,
'is_numeric'
,
'numeric'
),
self
::
TYPE_LESS_THAN
=>
array
(
true
,
'is_numeric'
,
'numeric'
),
self
::
TYPE_GREATER_THAN
=>
array
(
true
,
'is_numeric'
,
'numeric'
),
...
...
@@ -68,7 +68,7 @@ class EcomDev_PHPUnit_Constraint_Config_Node
*/
protected
function
evaluateEqualsString
(
$other
)
{
return
(
string
)
$other
===
$this
->
_expectedValue
;
return
$this
->
compareValues
(
$this
->
_expectedValue
,
(
string
)
$other
)
;
}
/**
...
...
@@ -88,7 +88,7 @@ class EcomDev_PHPUnit_Constraint_Config_Node
*/
protected
function
evaluateEqualsNumber
(
$other
)
{
return
(
float
)
$other
==
$this
->
_expectedValue
;
return
$this
->
compareValues
(
$this
->
_expectedValue
,
(
float
)
$other
)
;
}
/**
...
...
@@ -171,27 +171,10 @@ class EcomDev_PHPUnit_Constraint_Config_Node
*/
protected
function
evaluateEqualsXml
(
$other
)
{
// Normalize expected XML for matching appropriate xml structure without
// whitespaces, etc
if
(
!
$this
->
_expectedValue
instanceof
Varien_Simplexml_Element
)
{
try
{
if
(
$other
instanceof
SimpleXMLElement
)
{
$other
=
$other
->
asXML
();
}
$expectedXml
=
new
Varien_Simplexml_Element
(
$this
->
_expectedValue
);
}
catch
(
Exception
$e
)
{
throw
new
RuntimeException
(
sprintf
(
'Expected value is not an xml string for node %s, passed expected value: %s, parsing error: %s'
,
$this
->
_nodePath
,
PHPUnit_Util_Type
::
export
(
$this
->
_expectedValue
),
$e
->
getMessage
()
));
}
$expectedValue
=
$this
->
getXmlAsDom
(
$this
->
_expectedValue
);
$other
=
$this
->
getXmlAsDom
(
$other
);
$this
->
_expectedValue
=
$expectedXml
;
}
return
$this
->
_expectedValue
->
asNiceXml
()
==
$other
->
asNiceXml
();
return
$this
->
compareValues
(
$expectedValue
,
$other
);
}
...
...
lib/EcomDev/PHPUnit/Constraint/Config/Resource/Script.php
View file @
20b9f742
...
...
@@ -154,6 +154,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
self
::
FILE_UPGRADE_DATA
=>
array
(
'data'
,
'upgrade'
)
);
foreach
(
$directoryIterator
as
$entry
)
{
/* @var $entry SplFileInfo */
// We do not support scheme upgrade scripts with .sql
...
...
@@ -206,6 +207,9 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
*/
protected
function
getVersionScriptsDiff
(
$versions
,
$from
=
null
,
$to
=
null
,
$scriptPrefix
=
''
)
{
usort
(
$versions
[
'install'
],
array
(
$this
,
'compareVersions'
));
usort
(
$versions
[
'upgrade'
],
array
(
$this
,
'compareVersions'
));
if
(
$from
===
null
&&
end
(
$versions
[
'install'
]))
{
$version
=
end
(
$versions
[
'install'
]);
$from
=
$version
[
'from'
];
...
...
@@ -227,7 +231,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
$latestVersionFound
=
null
;
if
(
empty
(
$versions
[
'install'
])
&&
$from
!==
null
)
{
$expectedVersions
[]
=
sprintf
(
'install-%s.php'
,
$scriptPrefix
,
$from
);
$expectedVersions
[]
=
sprintf
(
'
%s
install-%s.php'
,
$scriptPrefix
,
$from
);
$latestVersionFound
=
$from
;
}
elseif
(
$from
!==
null
)
{
foreach
(
$versions
[
'install'
]
as
$index
=>
$version
)
{
...
...
modman
View file @
20b9f742
# EcomDev_PHPUnit definition
app/etc/modules/EcomDev_PHPUnit.xml app/etc/modules/EcomDev_PHPUnit.xml
app/code/community/EcomDev/PHPUnit app/code/community/EcomDev/PHPUnit
lib/EcomDev/PHPUnit lib/EcomDev/PHPUnit
lib/EcomDev/Utils lib/EcomDev/Utils
app/etc/modules/EcomDev_*.xml app/etc/modules/
app/code/community/EcomDev/* app/code/community/EcomDev/
lib/EcomDev/* lib/EcomDev/
lib/Spyc lib/Spyc
lib/vfsStream lib/vfsStream
shell/ecomdev-phpunit-install.php shell/ecomdev-phpunit-install.php
...
...
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