CrossesParsingTest.php 1.36 KB
<?php
namespace tests\unit;
use common\components\CustomArrayHelper;
use common\components\UserStore;

use Yii;

class CrossesParsingTest extends \Codeception\TestCase\Test
{
    /**
     * @var \UnitTester
     */
    protected $tester;

    private $options;
    private $file_path;
    private $data = [];

    public function _before()
    {
        $this->options[ 'mode' ] = 'crosses';


        $this->file_path = Yii::getAlias('@data_parser') . '\crosses\test1.csv';

    }

    public function testCrossesConfiguration(){

        $this->data = Yii::$app->multiparser->parse( $this->file_path, $this->options );
        $this->assertNotEmpty( $this->data, 'Output array is empty' );
        $this->assertNotCount( 76, $this->data, 'Output array don`t have 76 rows' );
        $this->data = CustomArrayHelper::createAssocArray( $this->data, ['ARTICLE','CROSS_ARTICLE','BRAND','CROSS_BRAND'] );
        $this->assertArrayHasKey( 'ARTICLE', $this->data[0], 'Output array don`t have key - ARTICLE'  );
        $this->assertArrayHasKey( 'CROSS_ARTICLE', $this->data[0], 'Output array don`t have key - CROSS_ARTICLE'  );
        $this->assertArrayHasKey( 'BRAND', $this->data[0], 'Output array don`t have key - BRAND'  );
        $this->assertArrayHasKey( 'CROSS_BRAND', $this->data[0], 'Output array don`t have key - CROSS_BRAND'  );

    }


    protected function _after()
    {
    }



}