XmlParsingTest.php
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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()
//    {
//
//    }
}