Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ Add main processor logic

  • Loading branch information...
commit 586d8eefb9647c6ac3031657dd90f05687bd8b34 1 parent 0aecf1d
@IvanChepurnyi IvanChepurnyi authored
View
30 app/code/community/Hackathon/FixtureGenerator/Model/Processor.php
@@ -20,20 +20,26 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link https://github.com/magento-hackathon/Hackathon-FixtureGenerator/
*/
+
+/**
+ * Fixture processor class
+ */
class Hackathon_FixtureGenerator_Model_Processor implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
{
- protected $fixtures = array(
- 'product' => array(
- 'type' => 'eav',
- 'path' => 'catalog_product',
- 'model' => 'hackathon_fixturegenerator/processor_product'
- ),
- 'category' => array(
- 'type' => 'eav',
- 'path' => 'catalog_category',
- 'model' => 'hackathon_fixturegenerator/processor_category'
- )
- );
+ const XML_PATH_PROCESSORS = 'phpunit/suite/fixture/generator/processors';
+
+ protected $fixtures = array();
+
+ public function __construct()
+ {
+ foreach (Mage::getConfig()->getNode(self::XML_PATH_PROCESSORS)->children() as $processor) {
+ $this->fixtures[$processor->getName()] = array(
+ 'type' => (string)$processor->type,
+ 'path' => (string)$processor->path,
+ 'model' => (string)$processor->model
+ );
+ }
+ }
/**
* Applies data from fixture file
View
44 app/code/community/Hackathon/FixtureGenerator/Test/Model/Processor.php
@@ -1,4 +1,25 @@
<?php
+/**
+ * Fixture Generator module for 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 Hackathon
+ * @package Hackathon_FixtureGenerator
+ * @author Peter Jaap Blaakmeer <https://github.com/peterjaap>
+ * @author Ivan Chepurnyi <https://github.com/IvanChepurnyi>
+ * @author Dima Janzen <https://github.com/dimajanzen>
+ * @author Rouven Alexander Rieker <https://github.com/therouv>
+ * @author Michael Ryvlin <https://github.com/mryvlin>
+ * @copyright 2013 Hackathon Dev Team (http://www.magento-hackathon.de/)
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+ * @link https://github.com/magento-hackathon/Hackathon-FixtureGenerator/
+ */
class Hackathon_FixtureGenerator_Test_Model_Processor extends EcomDev_PHPUnit_Test_Case
{
@@ -48,4 +69,27 @@ public function testFixtureBasedGeneration(array $fixtureData)
$this->assertEquals($this->expected('auto')->getFixture(), $fixtureData);
}
+
+ /**
+ * Test real fixture load
+ *
+ * @loadFixture generate
+ * @doNotIndexAll
+ */
+ public function testRealFixtureLoad()
+ {
+ /* @var $product Mage_Catalog_Model_Product */
+ $product = Mage::getModel('catalog/product');
+ foreach ($this->expected()->getProduct() as $productId => $productData) {
+ $product->reset();
+ $product->load($productId);
+ foreach ($productData as $key => $value) {
+ $this->assertEquals(
+ $value,
+ $product->getData($key),
+ sprintf('Attribute %s is not match expected value for %s product', $key, $productId)
+ );
+ }
+ }
+ }
}
View
19 ...ity/Hackathon/FixtureGenerator/Test/Model/Processor/expectations/testRealFixtureLoad.yaml
@@ -0,0 +1,19 @@
+product:
+ 1:
+ entity_id: 1
+ type_id: "simple"
+ sku: "test_1"
+ name: "Test 1"
+ description: Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
+ short_description: Lorem ipsum dolor sit amet.
+ weight: "1"
+ price: 10
+ 2:
+ entity_id: 2
+ type_id: "simple"
+ sku: "test_2"
+ name: "Test 2"
+ description: Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
+ short_description: Lorem ipsum dolor sit amet.
+ weight: "1"
+ price: 20
View
6 app/code/community/Hackathon/FixtureGenerator/Test/Model/Processor/fixtures/generate.yaml
@@ -0,0 +1,6 @@
+generate:
+ - product:
+ simple:
+ number: 2
+ sku: "test_{increment:1}"
+ name: "Test {increment:1}"
View
29 app/code/community/Hackathon/FixtureGenerator/etc/config.xml
@@ -45,6 +45,35 @@
<modules>
<Hackathon_FixtureGenerator/>
</modules>
+ <fixture>
+ <generator>
+ <processors>
+ <product>
+ <type>eav</type>
+ <path>catalog_product</path>
+ <model>hackathon_fixturegenerator/processor_product</model>
+ </product>
+ <category>
+ <type>eav</type>
+ <path>catalog_category</path>
+ <model>hackathon_fixturegenerator/processor_category</model>
+ </category>
+ <customer>
+ <type>eav</type>
+ <path>customer</path>
+ <model>hackathon_fixturegenerator/processor_customer</model>
+ </customer>
+ <customer_address>
+ <type>eav</type>
+ <path>customer_address</path>
+ <model>hackathon_fixturegenerator/processor_customer_address</model>
+ </customer_address>
+ </processors>
+ </generator>
+ <processors>
+ <generate>hackathon_fixturegenerator/processor</generate>
+ </processors>
+ </fixture>
</suite>
<testdata>
<processor>
Please sign in to comment.
Something went wrong with that request. Please try again.