Skip to main content

Add Columns Map test

  • All of the files are located inside: magento_root/app/code/community/RocketWeb/GoogleBaseFeedGenerator/ if not written otherwise!
  • In all YAML files be extremely careful of space denotation (using two spaces)!

Setting up default columns map

  1. Open test Test/Model/Generator.php and edit method RocketWeb_GoogleBaseFeedGenerator_Test_Model_Generator::getColumnsMap()

    /**
     * @test
     * @loadFixture feed
     * @loadFixture config
     * @loadExpectation
     * @dataProvider dataProvider
     */
    public function getColumnsMap($feedId)
    {
        // Comment out this line
        //$expected = $this->expected('map_%s', $feedId)->getData();
    
        $this->setModel();
        $map = $this->model->getColumnsMap();
    
        // Add this two lines
        $tmp = $this->toYaml($map, '  ');
        $this->debug($tmp);
    
        // Comment out this line
        //$this->assertEquals($expected, $map, "Columns map was changed!");
    }
  2. Open fixture Test/Model/Generator/fixtures/feed.yaml  and add new feed:

    tables:
      rw_gfeed_feed:
        - id: 101
          store_id: 0
          name: 'PHPUnit feed'
          type: 'generic'
          status: 1
        - id: 102
          store_id: 0
          name: 'PHPUnit feed'
          type: 'google_shoppings'
          status: 1
        # Copy a section and change id & type value, id must be 100+ (101, 102, 103, ...)
  3. Open fixture Test/Model/Generator/providers/getColumnMap.yaml and add:

    ... Existing lines ...
    -
      - 103 # Feed ID - add the ID from the previous step
  4. Run the test with filter (phpunit --filter getColumnsMap) and this time, you will receive an output inside the console:

     

     phpunit --filter getColumnsMap
    PHPUnit 4.7.6 by Sebastian Bergmann and contributors.
    .'
      id:
        column:id
        attribute:rw_gbase_directive_id
        param:0
        order:10
      title:
        column:title
        attribute:name
    ... MORE OUTPUT ...
        attribute:rw_gbase_directive_product_type_magento_category
        param:3
        order:120
    '
    .

    Copy the whole text between two qoutes (so lines from id to the end) for the last chunk (each feed will output this chunk)

  5. Open file Test/Model/Generator/expectations/getColumns.yaml and add:

    ... Existing code ...
    map_FEED_ID: # FEED_ID is the ID from step 2
      id:
        column:id
        ... The chunk copied in previous step ...
        attribute:rw_gbase_directive_product_type_magento_category
        param:3
        order:120
  6. Revert the changes in 1. step and rerun phpunit