Blame view

tests/unit/CrossesParsingTest.php 1.81 KB
51e6872d   Mihail   add custom test f...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  <?php
  namespace tests\unit;
  use common\components\UserStore;
  
  use Yii;
  
  class CrossesParsingTest extends \Codeception\TestCase\Test
  {
      /**
       * @var \UnitTester
       */
      protected $tester;
  
      private $options;
      private $file_path;
884c04ad   Mihail   fixed issues with...
16
      private $data = [];
51e6872d   Mihail   add custom test f...
17
18
19
20
  
      public function _before()
      {
          $this->options[ 'mode' ] = 'crosses';
884c04ad   Mihail   fixed issues with...
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  
          $this->options[ 'crosses' ] =  [
              'class' => 'common\components\parsers\CustomCsvParser',
              'auto_detect_first_line' => true,
              'min_column_quantity' => 4,
              'keys' =>['ARTICLE', 'CROSS_ARTICLE', 'BRAND', 'CROSS_BRAND'],
              'converter_conf' => [
          'class' => ' common\components\parsers\CustomConverter',
          'configuration' => [
              "brand"   => ['BRAND', 'CROSS_BRAND'],
              "crosses"   => [],
          ]]
          ];
  
51e6872d   Mihail   add custom test f...
35
36
37
38
39
40
          $this->file_path = Yii::getAlias('@data_parser') . '\crosses\test1.csv';
  
      }
  
      public function testReadCrosses(){
  
884c04ad   Mihail   fixed issues with...
41
42
43
44
45
46
47
48
          $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->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'  );
          $this->assertEquals(  $this->data[0]['BRAND'], strtoupper($this->data[0]['BRAND']),'BRAND not converted to upper case'  );
51e6872d   Mihail   add custom test f...
49
50
51
52
53
54
55
56
57
58
      }
  
  
      protected function _after()
      {
      }
  
  
  
  }