Completed
Push — master ( 566db7...17d057 )
by Alberto
04:54
created

ProcessorTest::testRun()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 35
rs 8.8571
cc 1
eloc 24
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 24 and the first side effect is on line 5.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace ADiaz\AML\OpenList\commands;
4
5
require __DIR__.'/../../../src/autoload.php';
6
7
use Symfony\Component\Console\Application;
8
use Symfony\Component\Console\Tester\CommandTester;
9
10
/**
11
 * This file is part of the OpenList Parser utility.
12
 *
13
 *
14
 * @category  PHP
15
 *
16
 * @author    Alberto Diaz <[email protected]>
17
 * @copyright 2016 Alberto Diaz <[email protected]>
18
 * @license   This source file is subject to the MIT license that is bundled
19
 *
20
 * @version   Release: @package_version@
21
 *
22
 * @link      http://tytem.com
23
 */
24
class ProcessorTest extends \PHPUnit_Framework_TestCase
25
{
26
    protected $project_path;
27
    protected $output_path;
28
29
    protected function setUp()
30
    {
31
        $this->output_path = __DIR__.'/../../../output/';
32
33
        if (!file_exists($this->output_path)) {
34
            mkdir($this->output_path, 0777, true);
35
        }
36
    }
37
38
    /**
39
     * Execute.
40
     */
41
    public function testRun()
42
    {
43
        $config = require __DIR__.'/../../../src/OpenList/conf/app.php';
44
45
        $application = new Application();
46
        $application->add(new Processor($config));
47
48
        $command = $application->find('process');
49
        $commandTester = new CommandTester($command);
50
        $commandTester->execute(array(
51
            'command' => $command->getName(),
52
        ));
53
54
        // check console result
55
        $this->assertRegExp('/'.Processor::FINISH_OK.'/', $commandTester->getDisplay());
56
57
        // check if exported files exists
58
        $this->assertFileExists($this->output_path.'all'.date('_Y-m-d').'.json');
59
        $this->assertFileExists($this->output_path.'ukhmt'.date('_Y-m-d').'.json');
60
        $this->assertFileExists($this->output_path.'usofac'.date('_Y-m-d').'.json');
61
        $this->assertFileExists($this->output_path.'unsc'.date('_Y-m-d').'.json');
62
        $this->assertFileExists($this->output_path.'ukhmt'.date('_Y-m-d').'.serialized');
63
        $this->assertFileExists($this->output_path.'usofac'.date('_Y-m-d').'.serialized');
64
        $this->assertFileExists($this->output_path.'unsc'.date('_Y-m-d').'.serialized');
65
66
        // check the size of the files exported
67
        $this->assertTrue(filesize($this->output_path.'all'.date('_Y-m-d').'.json') > 10000);
68
        $this->assertTrue(filesize($this->output_path.'ukhmt'.date('_Y-m-d').'.json') > 10000);
69
        $this->assertTrue(filesize($this->output_path.'usofac'.date('_Y-m-d').'.json') > 10000);
70
        $this->assertTrue(filesize($this->output_path.'unsc'.date('_Y-m-d').'.json') > 10000);
71
        $this->assertTrue(filesize($this->output_path.'ukhmt'.date('_Y-m-d').'.serialized') > 10000);
72
        $this->assertTrue(filesize($this->output_path.'usofac'.date('_Y-m-d').'.serialized') > 10000);
73
        $this->assertTrue(filesize($this->output_path.'unsc'.date('_Y-m-d').'.serialized') > 10000);
74
        $this->assertTrue(filesize($this->output_path.'all'.date('_Y-m-d').'.json') > 10000);
75
    }
76
}
77