XmlParsingTest.php 1.84 KB
<?php
namespace tests\unit;
use common\components\UserStore;

use Yii;

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

    private $options;
    private $file_path;
    private $data;

    public function _before()
    {
        $this->data = [];
        $this->options[ 'mode' ] = 'console';
       // $this->options[ 'keys' ] = [ 'DESCR', 'ARTICLE', 'BRAND', 'BOX', 'PRICE' ];
        $this->file_path = Yii::getAlias('@data_parser') . '\xml_parser\console.xml';

    }

    public function testConsoleReadXml(){

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

    }


//    public function imagineCustomer(){
//        $fake = \Faker\Factory::create();
//        return [
//            'name' => $fake->name,
//            'email' => $fake->email,
//            'pass' => $fake->password(19),
//        ];
//
//    }
//
//    public function testGetUser(){
//        $imagineUser = $this->imagineCustomer();
//        $this->store->addUser($imagineUser['name'],$imagineUser['email'],$imagineUser['pass']);
//        $user = $this->store->getUser($imagineUser['email']);
//        $this->assertEquals($user['name'], $imagineUser['name']);
//        $this->assertEquals($user['email'], $imagineUser['email']);
//        $this->assertEquals($user['pass'], $imagineUser['pass']);
//    }
//
//    public function testAddUser_ShortPass(){
//        $this->setExpectedException('\yii\base\Exception');
//        $this->store->addUser('Some Name','collmail@gig.com','ff');
//    }

    protected function _after()
    {
    }

    // tests
//    public function testMe()
//    {
//
//    }

}