Add Feed File test
Open extension file
Model/Config.phpand edit methodRocketWeb_GoogleBaseFeedGenerator_Model_Config::_beforeSave()to a public method (we are modifying the extension file - only temporary)/** * Processing object after save data. Form data preparation after submitting. * * @return Mage_Core_Model_Abstract */ public function _beforeSave() { switch($this->getPath()) { ... The rest of the method ...Open fixture
Test/Model/SimpleProduct/fixtures/testRunFeeds.yamland add new feed:tables: rw_gfeed_feed: - id: 101 store_id: 0 name: 'Generic feed unit test' type: 'generic' status: 1 - id: 102 store_id: 0 name: 'Generic feed unit test with tax' type: 'generic' status: 1 - id: 103 store_id: 0 name: 'Google shopping feed unit test' type: 'google_shopping' status: 1 # Copy a section and change id & type valueOpen test
Test/Model/SimpleProduct.phpand uncomment methodRocketWeb_GoogleBaseFeedGenerator_Test_Model_SimpleProduct::generateFeedConfig()and add \@ to the phpDocs:/** * test //- add @ * loadFixtures testRunFeeds //- add @ */ public function generateFeedConfig() { $feedId = 1; // Change to ID from step 2! parent::generateFeedConfig($feedId); }Run the test with filter (phpunit --filter generateFeedConfig) and you will receive an output inside the console:
$ phpunit --filter generateFeedConfig PHPUnit 4.7.6 by Sebastian Bergmann and contributors. Warning: Deprecated configuration setting "strict" used ' - feed_id: 3 path: general_name value: - feed_id: 3 value: 168 ... The rest of the output ... - feed_id: 3 path: shipping_carrier_realtime value: ups,usps,fedex,dhl,dhlint ' . Time: 632 ms, Memory: 24.00Mb OK (1 test, 0 assertions)Open data provider
Test/Model/SimpleProduct/fixtures/testRunConfigs.yamland add the chunk you copied in the previous step (make sure that the alignment is correct):... Existing lines ... # -------------------------------- # Default simple product feed. # type: google_shopping # Add your type # tax: no - feed_id: 103 path: general_name value: - feed_id: 103 value: 168 ... The rest of the output ... - feed_id: 103 path: shipping_carrier_realtime value: ups,usps,fedex,dhl,dhlintBe careful!
Make sure you enclose all serialized strings, otherwise you will receive an error when running phpunit!
Also:- replace value for path
categories_provider_taxonomy_by_categoryby:'{"4":{"category":"4","value":"Women -> Test","disabled":false},"5":{"category":"5","value":"Men -> Test","disabled":false}}'
- remove paths:
general_name, general_store_id - add value for path
general_currency: USD - change path
general_feed_dirtovar/feeds - don't forget to add the comment at the top of the new chunk (so its more readable)
- replace value for path
- Reverse the change from 1. step (from public to protected) and comment back the method from 3. step (also remove \@)
Open provider
Test/Model/SimpleProduct/providers/simpleProductsFeeds.yamland add new provider line:- - 101 #Feed ID - tax: 0 - - 102 #Feed ID - tax: 10 - - 103 #Feed ID - tax: 0 # Copy a section and change feed id to the one added 2. step, add under tax new line with "debug: 1" - - FeedId - tax :0 debug: 1Then run the test:
phpunit --filter simpleProductsFeeds$ phpunit --filter simpleProductsFeeds PHPUnit 4.7.6 by Sebastian Bergmann and contributors. 'id item_group_id title description link image_link additional_image_link price sale_price sale_price_effective_date availability shipping_weight brand mpn condition product_type google_product_category identifier_exists is_bundle 1231000231 Book Book http://local.gsf2.dev/index.php/catalog/product/view/id/1231000231/s/book/?utm_source=google_shopping http://local.gsf2.dev/media/catalog/product/1231.jpg 1231.31 USD 1100.31 USD out of stock 0.00 lb not specified msj000 new TRUE FALSE 1232000232 Book Book http://local.gsf2.dev/index.php/catalog/product/view/id/1232000232/s/book/?utm_source=google_shopping http://local.gsf2.dev/media/catalog/product/1232.jpg 1232.32 USD 1100.32 USD out of stock 0.00 lb not specified msj001 new TRUE FALSE 1233000233 Book Book http://local.gsf2.dev/index.php/catalog/product/view/id/1233000233/s/book/?utm_source=google_shopping http://local.gsf2.dev/media/catalog/product/1233.jpg 2032.00 USD 1100.33 USD out of stock 0.00 lb not specified msj002 new TRUE FALSE' . Time: 2.59 seconds, Memory: 51.00Mb OK (1 test, 0 assertions)
Copy everything in between the single qoutes (') and paste it into
Test/Model/SimpleProducts/expectations/simpleProductsFeeds.yaml#feed_FeedID_HasVAT feed_103_0: #Simple products, google_shopping result: - 'id item_group_id title description link image_link additional_image_link price sale_price sale_price_effective_date availability shipping_weight brand mpn condition product_type google_product_category identifier_exists is_bundle' - '1231000231 Book Book http://local.gsf2.dev/index.php/catalog/product/view/id/1231000231/s/book/?utm_source=google_shopping http://local.gsf2.dev/media/catalog/product/1231.jpg 1231.31 USD 1100.31 USD out of stock 0.00 lb not specified msj000 new TRUE FALSE' - '1232000232 Book Book http://local.gsf2.dev/index.php/catalog/product/view/id/1232000232/s/book/?utm_source=google_shopping http://local.gsf2.dev/media/catalog/product/1232.jpg 1232.32 USD 1100.32 USD out of stock 0.00 lb not specified msj001 new TRUE FALSE' - '1233000233 Book Book http://local.gsf2.dev/index.php/catalog/product/view/id/1233000233/s/book/?utm_source=google_shopping http://local.gsf2.dev/media/catalog/product/1233.jpg 2032.00 USD 1100.33 USD out of stock 0.00 lb not specified msj002 new TRUE FALSE'Notice that each line is enclosed as a string.
- Open provider
Test/Model/SimpleProducts/providers/simpleProductsFeeds.yamlremovedebug: 1line and run full unit testphpunit$ phpunit PHPUnit 4.7.6 by Sebastian Bergmann and contributors. .............. Time: 4.57 seconds, Memory: 52.50Mb OK (14 tests, 17 assertions)
Well, this is it for the simple products. Now redo this whole section, replacing wording "SimpleProducts" with "ConfigurableProducts"
No comments to display
No comments to display