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
*
* @see Mage_Core_Controller_Request_Http::getBaseUrl()
*/
public function getBaseUrl()
public function getBaseUrl($raw = false)
{
return $this->_baseUrl;
}
......
......@@ -124,11 +124,11 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
*/
public function getModelInstance($modelClass='', $constructArguments=array())
{
if (!isset($this->_replaceInstanceCreation['model'][$modelClass])) {
return parent::getModelInstance($modelClass, $constructArguments);
if (!isset($this->_replaceInstanceCreation['model'][(string)$modelClass])) {
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
public function loadByTestCase(PHPUnit_Framework_TestCase $testCase)
{
$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);
......@@ -412,7 +412,7 @@ class EcomDev_PHPUnit_Model_Fixture
if (empty($this->_fixture)) {
$this->_fixture = $data;
} else {
$this->_fixture = array_merge_recursive($this->_fixture, $data);
$this->_fixture = array_replace_recursive($this->_fixture, $data);
}
return $this;
......
......@@ -173,6 +173,16 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config
$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);
return $this;
}
......
......@@ -112,7 +112,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractEav
$this->_originalIndexers = $this->_requiredIndexers;
if (!empty($this->_options['addRequiredIndex'])) {
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) {
$this->_requiredIndexers[] = $match[2];
}
......
......@@ -50,6 +50,8 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
$suite = new self('Magento Test Suite');
$excludedModules = Mage::getConfig()->getNode('phpunit/suite/exclude');
// Walk through different groups in modules for finding test cases
foreach ($groups->children() as $group) {
foreach ($modules->children() as $module) {
......@@ -59,6 +61,10 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
continue;
}
if (isset($excludedModules->{$module->getName()})) {
continue;
}
$moduleCodeDir = Mage::getBaseDir('code') . DS . (string) $realModule->codePool;
$searchPath = Mage::getModuleDir('', $module->getName()) . DS . 'Test' . DS . (string) $group;
......
......@@ -68,9 +68,18 @@ class EcomDev_PHPUnit_Test_Suite_Group extends PHPUnit_Framework_TestSuite
* impossibility for specifying group by parent test case
* Because it is a very dirty hack :(
**/
$testGroups = array();
$testGroups = EcomDev_Utils_Reflection::getRestrictedPropertyValue($test, 'groups');
foreach ($groups as $group) {
if(!isset($testGroups[$group])) {
$testGroups[$group] = $test->tests();
} else {
foreach($test->tests() as $subTest) {
if(!in_array($subTest, $testGroups[$group], true)) {
$testGroups[$group][] = $subTest;
}
}
}
}
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
......
......@@ -55,6 +55,8 @@
</global>
<phpunit>
<suite>
<modules /> <!-- List of modules included into test suite -->
<exclude /> <!-- List of modules that are excluded from test suite -->
<yaml>
<model>ecomdev_phpunit/yaml_loader</model>
<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 @@
"magento-hackathon/magento-composer-installer": "*",
"phpunit/phpunit": "4.1.*"
},
"replace": {
"ivanchepurnyi/ecomdev_phpunit":"*"
},
"authors":[
{
"name":"Ivan Chepurnyi"
......
......@@ -81,7 +81,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block_Property
* (non-PHPdoc)
* @see EcomDev_PHPUnit_ConstraintAbstract::getActualValue()
*/
protected function getActualValue($other)
protected function getActualValue($other = null)
{
if ($this->_useActualValue) {
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