Skip to content

Commit c2c493f

Browse files
committed
Merge branch 'release/0.3.4'
2 parents 2b22f38 + 8b2723a commit c2c493f

12 files changed

Lines changed: 116 additions & 10 deletions

File tree

app/code/community/EcomDev/PHPUnit/Controller/Request/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public function getHttpHost($trimPort = false)
372372
*
373373
* @see Mage_Core_Controller_Request_Http::getBaseUrl()
374374
*/
375-
public function getBaseUrl()
375+
public function getBaseUrl($raw = false)
376376
{
377377
return $this->_baseUrl;
378378
}

app/code/community/EcomDev/PHPUnit/Model/Config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ public function flushReplaceInstanceCreation()
124124
*/
125125
public function getModelInstance($modelClass='', $constructArguments=array())
126126
{
127-
if (!isset($this->_replaceInstanceCreation['model'][$modelClass])) {
128-
return parent::getModelInstance($modelClass, $constructArguments);
127+
if (!isset($this->_replaceInstanceCreation['model'][(string)$modelClass])) {
128+
return parent::getModelInstance((string)$modelClass, $constructArguments);
129129
}
130130

131-
return $this->_replaceInstanceCreation['model'][$modelClass];
131+
return $this->_replaceInstanceCreation['model'][(string)$modelClass];
132132
}
133133

134134
/**

app/code/community/EcomDev/PHPUnit/Model/Fixture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function isScopeDefault()
301301
public function loadByTestCase(PHPUnit_Framework_TestCase $testCase)
302302
{
303303
$fixtures = EcomDev_PHPUnit_Test_Case_Util::getAnnotationByNameFromClass(
304-
get_class($testCase), 'loadFixture', array('class', 'method'), $testCase->getName(false)
304+
get_class($testCase), 'loadFixture', array('method', 'class'), $testCase->getName(false)
305305
);
306306

307307
$this->_loadFixtureFiles($fixtures, $testCase);
@@ -412,7 +412,7 @@ public function loadYaml($filePath)
412412
if (empty($this->_fixture)) {
413413
$this->_fixture = $data;
414414
} else {
415-
$this->_fixture = array_merge_recursive($this->_fixture, $data);
415+
$this->_fixture = array_replace_recursive($this->_fixture, $data);
416416
}
417417

418418
return $this;

app/code/community/EcomDev/PHPUnit/Model/Fixture/Processor/Config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ protected function _setConfigNodeValue($path, $value)
173173
$value = $backend->getValue();
174174
}
175175

176+
if (is_array($value)) {
177+
Mage::throwException(
178+
sprintf(
179+
'There is a collision in configuration value %s. Got: %s',
180+
$path,
181+
print_r($value, true)
182+
)
183+
);
184+
}
185+
176186
Mage::getConfig()->setNode($path, $value);
177187
return $this;
178188
}

app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture/AbstractEav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function loadEntity($entityType, $values)
112112
$this->_originalIndexers = $this->_requiredIndexers;
113113
if (!empty($this->_options['addRequiredIndex'])) {
114114
foreach ($this->_options['addRequiredIndex'] as $data) {
115-
if (preg_match('/^([a-z0-9_\\-])+\\s+([a-z0-9_\\-])\s*$/i', $data, $match)
115+
if (preg_match('/^([a-z0-9_\\-]+)\\s+([a-z0-9_\\-]+)\s*$/i', $data, $match)
116116
&& $match[1] == $entityType) {
117117
$this->_requiredIndexers[] = $match[2];
118118
}

app/code/community/EcomDev/PHPUnit/Test/Suite.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public static function suite()
5050

5151
$suite = new self('Magento Test Suite');
5252

53+
$excludedModules = Mage::getConfig()->getNode('phpunit/suite/exclude');
54+
5355
// Walk through different groups in modules for finding test cases
5456
foreach ($groups->children() as $group) {
5557
foreach ($modules->children() as $module) {
@@ -58,6 +60,10 @@ public static function suite()
5860
$suite->addTest(self::warning('There is no module with name: ' . $module->getName()));
5961
continue;
6062
}
63+
64+
if (isset($excludedModules->{$module->getName()})) {
65+
continue;
66+
}
6167

6268
$moduleCodeDir = Mage::getBaseDir('code') . DS . (string) $realModule->codePool;
6369
$searchPath = Mage::getModuleDir('', $module->getName()) . DS . 'Test' . DS . (string) $group;

app/code/community/EcomDev/PHPUnit/Test/Suite/Group.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,18 @@ public function __construct($theClass = '', $groups = array())
6868
* impossibility for specifying group by parent test case
6969
* Because it is a very dirty hack :(
7070
**/
71-
$testGroups = array();
71+
$testGroups = EcomDev_Utils_Reflection::getRestrictedPropertyValue($test, 'groups');
72+
7273
foreach ($groups as $group) {
73-
$testGroups[$group] = $test->tests();
74+
if(!isset($testGroups[$group])) {
75+
$testGroups[$group] = $test->tests();
76+
} else {
77+
foreach($test->tests() as $subTest) {
78+
if(!in_array($subTest, $testGroups[$group], true)) {
79+
$testGroups[$group][] = $subTest;
80+
}
81+
}
82+
}
7483
}
7584

7685
EcomDev_Utils_Reflection::setRestrictedPropertyValue(

app/code/community/EcomDev/PHPUnit/etc/config.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
</global>
5656
<phpunit>
5757
<suite>
58+
<modules /> <!-- List of modules included into test suite -->
59+
<exclude /> <!-- List of modules that are excluded from test suite -->
5860
<yaml>
5961
<model>ecomdev_phpunit/yaml_loader</model>
6062
<loaders>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* @loadSharedFixture testFixtureArrayMerge.yaml
4+
*/
5+
class EcomDev_PHPUnitTest_Test_Model_Fixture extends EcomDev_PHPUnit_Test_Case
6+
{
7+
8+
public function testFixtureArrayMerge()
9+
{
10+
require_once($this->_getVfsUrl('app/code/community/EcomDev/PHPUnit/Test/Model/ExampleClass.php'));
11+
12+
$testCase = new EcomDev_PHPUnitTest_Test_Model_ExampleClass();
13+
$testCase->setName('testLoadFixtureOrder');
14+
$this->getFixture()->loadForClass(get_class($testCase));
15+
$this->getFixture()->loadByTestCase($testCase);
16+
$this->getFixture()->apply();
17+
}
18+
19+
public function testLoadClassBeforeMethodFixtures()
20+
{
21+
require_once($this->_getVfsUrl('app/code/community/EcomDev/PHPUnit/Test/Model/ExampleClass.php'));
22+
23+
$testCase = new EcomDev_PHPUnitTest_Test_Model_ExampleClass();
24+
$testCase->setName('testLoadFixtureOrder');
25+
$this->getFixture()->loadForClass(get_class($testCase));
26+
$this->getFixture()->loadByTestCase($testCase);
27+
$this->getFixture()->apply();
28+
$this->assertEquals('methodFixtureValue', Mage::getStoreConfig('sample/path'));
29+
}
30+
31+
protected function _getVfsUrl($path)
32+
{
33+
return $this->getFixture()->getVfs()->url($path);
34+
}
35+
36+
37+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
vfs:
2+
app:
3+
code:
4+
community:
5+
EcomDev:
6+
PHPUnit:
7+
Test:
8+
Model:
9+
ExampleClass.php: |
10+
<?php
11+
12+
/**
13+
* @loadSharedFixture sharedClassFixture.yaml
14+
* @loadFixture classFixture.yaml
15+
*/
16+
class EcomDev_PHPUnitTest_Test_Model_ExampleClass extends EcomDev_PHPUnit_Test_Case
17+
{
18+
/**
19+
* @loadSharedFixture sharedMethodFixture.yaml
20+
* @loadFixture methodFixture.yaml
21+
*/
22+
public function testLoadFixtureOrder()
23+
{
24+
25+
}
26+
}
27+
fixtures:
28+
classFixture.yaml: >
29+
config:
30+
default/sample/path: classFixtureValue
31+
sharedClassFixture.yaml: >
32+
config:
33+
default/sample/path: sharedClassFixtureValue
34+
sharedMethodFixture.yaml: >
35+
config:
36+
default/sample/path: sharedMethodFixtureValue
37+
methodFixture.yaml: >
38+
config:
39+
default/sample/path: methodFixtureValue

0 commit comments

Comments
 (0)