Completed
Push — master ( 85de5a...b7b261 )
by Alberto
05:33
created

ProcessorTest::testRun()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 46
rs 8.9411
cc 1
eloc 30
nc 1
nop 0
1
<?php
2
3
namespace ADiaz\AML\OpenList\commands;
4
5
use Symfony\Component\Console\Application;
6
use Symfony\Component\Console\Tester\CommandTester;
7
8
/**
9
 * This file is part of the OpenList Parser utility.
10
 *
11
 *
12
 * @category  PHP
13
 *
14
 * @author    Alberto Diaz <[email protected]>
15
 * @copyright 2016 Alberto Diaz <[email protected]>
16
 * @license   This source file is subject to the MIT license that is bundled
17
 *
18
 * @version   Release: @package_version@
19
 *
20
 * @link      http://tytem.com
21
 */
22
class ProcessorTest extends \PHPUnit_Framework_TestCase
23
{
24
    protected $project_path;
25
    protected $output_path;
26
27
    protected function setUp()
28
    {
29
        $list_path = __DIR__.'/../../../lists/';
30
31
        if (!file_exists($list_path)) {
32
            mkdir($list_path, 0777, true);
33
        }
34
35
        $this->output_path = __DIR__.'/../../../output/';
36
37
        if (!file_exists($this->output_path)) {
38
            mkdir($this->output_path, 0777, true);
39
        }
40
    }
41
42
    /**
43
     * Execute.
44
     */
45
     /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
    public function testRun()
47
    {
48
        $config = require __DIR__.'/../../../src/OpenList/conf/app.php';
49
50
        // Before execute this test, it is necessary to execute the command receive
51
        $applicationReceiver = new Application();
52
        $applicationReceiver->add(new Receiver($config));
53
54
        $commandReceiver = $applicationReceiver->find('receive');
55
        $commandTesterReceiver = new CommandTester($commandReceiver);
56
        $commandTesterReceiver->execute(array(
57
            'command' => $commandReceiver->getName(),
58
        ));
59
60
        // Start processing
61
        $application = new Application();
62
        $application->add(new Processor($config));
63
64
        $command = $application->find('process');
65
        $commandTester = new CommandTester($command);
66
        $commandTester->execute(array(
67
            'command' => $command->getName(),
68
        ));
69
70
        // check console result
71
        $this->assertRegExp('/'.Processor::FINISH_OK.'/', $commandTester->getDisplay());
72
73
        // check if exported files exists
74
        $this->assertFileExists($this->output_path.'all'.date('_Y-m-d').'.json');
75
        $this->assertFileExists($this->output_path.'ukhmt'.date('_Y-m-d').'.json');
76
        $this->assertFileExists($this->output_path.'usofac'.date('_Y-m-d').'.json');
77
        $this->assertFileExists($this->output_path.'unsc'.date('_Y-m-d').'.json');
78
        $this->assertFileExists($this->output_path.'ukhmt'.date('_Y-m-d').'.serialized');
79
        $this->assertFileExists($this->output_path.'usofac'.date('_Y-m-d').'.serialized');
80
        $this->assertFileExists($this->output_path.'unsc'.date('_Y-m-d').'.serialized');
81
82
        // check the size of the files exported
83
        $this->assertTrue(filesize($this->output_path.'all'.date('_Y-m-d').'.json') > 10000);
84
        $this->assertTrue(filesize($this->output_path.'ukhmt'.date('_Y-m-d').'.json') > 10000);
85
        $this->assertTrue(filesize($this->output_path.'usofac'.date('_Y-m-d').'.json') > 10000);
86
        $this->assertTrue(filesize($this->output_path.'unsc'.date('_Y-m-d').'.json') > 10000);
87
        $this->assertTrue(filesize($this->output_path.'ukhmt'.date('_Y-m-d').'.serialized') > 10000);
88
        $this->assertTrue(filesize($this->output_path.'usofac'.date('_Y-m-d').'.serialized') > 10000);
89
        $this->assertTrue(filesize($this->output_path.'unsc'.date('_Y-m-d').'.serialized') > 10000);
90
        $this->assertTrue(filesize($this->output_path.'all'.date('_Y-m-d').'.json') > 10000);
91
    }
92
    */
93
}
94