Commit c2c493f4 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Merge branch 'release/0.3.4'

parents 2b22f38f 8b2723a3
...@@ -372,7 +372,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -372,7 +372,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* *
* @see Mage_Core_Controller_Request_Http::getBaseUrl() * @see Mage_Core_Controller_Request_Http::getBaseUrl()
*/ */
public function getBaseUrl() public function getBaseUrl($raw = false)
{ {
return $this->_baseUrl; return $this->_baseUrl;
} }
......
...@@ -124,11 +124,11 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config ...@@ -124,11 +124,11 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
*/ */
public function getModelInstance($modelClass='', $constructArguments=array()) public function getModelInstance($modelClass='', $constructArguments=array())
{ {
if (!isset($this->_replaceInstanceCreation['model'][$modelClass])) { if (!isset($this->_replaceInstanceCreation['model'][(string)$modelClass])) {
return parent::getModelInstance($modelClass, $constructArguments); return parent::getModelInstance((string)$modelClass, $constructArguments);
} }
return $this->_replaceInstanceCreation['model'][$modelClass]; return $this->_replaceInstanceCreation['model'][(string)$modelClass];
} }
/** /**
......
...@@ -301,7 +301,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -301,7 +301,7 @@ class EcomDev_PHPUnit_Model_Fixture
public function loadByTestCase(PHPUnit_Framework_TestCase $testCase) public function loadByTestCase(PHPUnit_Framework_TestCase $testCase)
{ {
$fixtures = EcomDev_PHPUnit_Test_Case_Util::getAnnotationByNameFromClass( $fixtures = EcomDev_PHPUnit_Test_Case_Util::getAnnotationByNameFromClass(
get_class($testCase), 'loadFixture', array('class', 'method'), $testCase->getName(false) get_class($testCase), 'loadFixture', array('method', 'class'), $testCase->getName(false)
); );
$this->_loadFixtureFiles($fixtures, $testCase); $this->_loadFixtureFiles($fixtures, $testCase);
...@@ -412,7 +412,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -412,7 +412,7 @@ class EcomDev_PHPUnit_Model_Fixture
if (empty($this->_fixture)) { if (empty($this->_fixture)) {
$this->_fixture = $data; $this->_fixture = $data;
} else { } else {
$this->_fixture = array_merge_recursive($this->_fixture, $data); $this->_fixture = array_replace_recursive($this->_fixture, $data);
} }
return $this; return $this;
......
...@@ -173,6 +173,16 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config ...@@ -173,6 +173,16 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config
$value = $backend->getValue(); $value = $backend->getValue();
} }
if (is_array($value)) {
Mage::throwException(
sprintf(
'There is a collision in configuration value %s. Got: %s',
$path,
print_r($value, true)
)
);
}
Mage::getConfig()->setNode($path, $value); Mage::getConfig()->setNode($path, $value);
return $this; return $this;
} }
......
...@@ -112,7 +112,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractEav ...@@ -112,7 +112,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractEav
$this->_originalIndexers = $this->_requiredIndexers; $this->_originalIndexers = $this->_requiredIndexers;
if (!empty($this->_options['addRequiredIndex'])) { if (!empty($this->_options['addRequiredIndex'])) {
foreach ($this->_options['addRequiredIndex'] as $data) { foreach ($this->_options['addRequiredIndex'] as $data) {
if (preg_match('/^([a-z0-9_\\-])+\\s+([a-z0-9_\\-])\s*$/i', $data, $match) if (preg_match('/^([a-z0-9_\\-]+)\\s+([a-z0-9_\\-]+)\s*$/i', $data, $match)
&& $match[1] == $entityType) { && $match[1] == $entityType) {
$this->_requiredIndexers[] = $match[2]; $this->_requiredIndexers[] = $match[2];
} }
......
...@@ -50,6 +50,8 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite ...@@ -50,6 +50,8 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
$suite = new self('Magento Test Suite'); $suite = new self('Magento Test Suite');
$excludedModules = Mage::getConfig()->getNode('phpunit/suite/exclude');
// 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) {
...@@ -59,6 +61,10 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite ...@@ -59,6 +61,10 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
continue; continue;
} }
if (isset($excludedModules->{$module->getName()})) {
continue;
}
$moduleCodeDir = Mage::getBaseDir('code') . DS . (string) $realModule->codePool; $moduleCodeDir = Mage::getBaseDir('code') . DS . (string) $realModule->codePool;
$searchPath = Mage::getModuleDir('', $module->getName()) . DS . 'Test' . DS . (string) $group; $searchPath = Mage::getModuleDir('', $module->getName()) . DS . 'Test' . DS . (string) $group;
......
...@@ -68,9 +68,18 @@ class EcomDev_PHPUnit_Test_Suite_Group extends PHPUnit_Framework_TestSuite ...@@ -68,9 +68,18 @@ class EcomDev_PHPUnit_Test_Suite_Group extends PHPUnit_Framework_TestSuite
* impossibility for specifying group by parent test case * impossibility for specifying group by parent test case
* Because it is a very dirty hack :( * Because it is a very dirty hack :(
**/ **/
$testGroups = array(); $testGroups = EcomDev_Utils_Reflection::getRestrictedPropertyValue($test, 'groups');
foreach ($groups as $group) { foreach ($groups as $group) {
if(!isset($testGroups[$group])) {
$testGroups[$group] = $test->tests(); $testGroups[$group] = $test->tests();
} else {
foreach($test->tests() as $subTest) {
if(!in_array($subTest, $testGroups[$group], true)) {
$testGroups[$group][] = $subTest;
}
}
}
} }
EcomDev_Utils_Reflection::setRestrictedPropertyValue( EcomDev_Utils_Reflection::setRestrictedPropertyValue(
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
</global> </global>
<phpunit> <phpunit>
<suite> <suite>
<modules /> <!-- List of modules included into test suite -->
<exclude /> <!-- List of modules that are excluded from test suite -->
<yaml> <yaml>
<model>ecomdev_phpunit/yaml_loader</model> <model>ecomdev_phpunit/yaml_loader</model>
<loaders> <loaders>
......
<?php
/**
* @loadSharedFixture testFixtureArrayMerge.yaml
*/
class EcomDev_PHPUnitTest_Test_Model_Fixture extends EcomDev_PHPUnit_Test_Case
{
public function testFixtureArrayMerge()
{
require_once($this->_getVfsUrl('app/code/community/EcomDev/PHPUnit/Test/Model/ExampleClass.php'));
$testCase = new EcomDev_PHPUnitTest_Test_Model_ExampleClass();
$testCase->setName('testLoadFixtureOrder');
$this->getFixture()->loadForClass(get_class($testCase));
$this->getFixture()->loadByTestCase($testCase);
$this->getFixture()->apply();
}
public function testLoadClassBeforeMethodFixtures()
{
require_once($this->_getVfsUrl('app/code/community/EcomDev/PHPUnit/Test/Model/ExampleClass.php'));
$testCase = new EcomDev_PHPUnitTest_Test_Model_ExampleClass();
$testCase->setName('testLoadFixtureOrder');
$this->getFixture()->loadForClass(get_class($testCase));
$this->getFixture()->loadByTestCase($testCase);
$this->getFixture()->apply();
$this->assertEquals('methodFixtureValue', Mage::getStoreConfig('sample/path'));
}
protected function _getVfsUrl($path)
{
return $this->getFixture()->getVfs()->url($path);
}
}
vfs:
app:
code:
community:
EcomDev:
PHPUnit:
Test:
Model:
ExampleClass.php: |
<?php
/**
* @loadSharedFixture sharedClassFixture.yaml
* @loadFixture classFixture.yaml
*/
class EcomDev_PHPUnitTest_Test_Model_ExampleClass extends EcomDev_PHPUnit_Test_Case
{
/**
* @loadSharedFixture sharedMethodFixture.yaml
* @loadFixture methodFixture.yaml
*/
public function testLoadFixtureOrder()
{
}
}
fixtures:
classFixture.yaml: >
config:
default/sample/path: classFixtureValue
sharedClassFixture.yaml: >
config:
default/sample/path: sharedClassFixtureValue
sharedMethodFixture.yaml: >
config:
default/sample/path: sharedMethodFixtureValue
methodFixture.yaml: >
config:
default/sample/path: methodFixtureValue
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
"magento-hackathon/magento-composer-installer": "*", "magento-hackathon/magento-composer-installer": "*",
"phpunit/phpunit": "4.1.*" "phpunit/phpunit": "4.1.*"
}, },
"replace": {
"ivanchepurnyi/ecomdev_phpunit":"*"
},
"authors":[ "authors":[
{ {
"name":"Ivan Chepurnyi" "name":"Ivan Chepurnyi"
......
...@@ -81,7 +81,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block_Property ...@@ -81,7 +81,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block_Property
* (non-PHPdoc) * (non-PHPdoc)
* @see EcomDev_PHPUnit_ConstraintAbstract::getActualValue() * @see EcomDev_PHPUnit_ConstraintAbstract::getActualValue()
*/ */
protected function getActualValue($other) protected function getActualValue($other = null)
{ {
if ($this->_useActualValue) { if ($this->_useActualValue) {
if ($this->_actualValue instanceof Varien_Object) { if ($this->_actualValue instanceof Varien_Object) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment