Passed
Push — master ( 2ce550...554c58 )
by Marcin
50s queued 10s
created

ApiTest::testConstruct_1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by Marcin.
4
 * Date: 03.03.2019
5
 * Time: 17:07
6
 */
7
8
namespace Tests\Mrcnpdlk\Api\Unoconv;
9
10
use Mrcnpdlk\Api\Unoconv\Api;
11
use Mrcnpdlk\Api\Unoconv\Config;
12
use Mrcnpdlk\Api\Unoconv\Enum\FormatType;
13
use Mrcnpdlk\Api\Unoconv\Exception\InvalidFileArgumentException;
14
use Mrcnpdlk\Api\Unoconv\Exception\UnoconvException;
15
use PHPUnit\Framework\TestCase;
16
17
class ApiTest extends TestCase
18
{
19
    /**
20
     * @throws \Mrcnpdlk\Api\Unoconv\Exception
21
     */
22
    public function testConstruct_1(): void
23
    {
24
        $oApi = new Api();
0 ignored issues
show
Unused Code introduced by
$oApi is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
        $this->assertTrue(true);
26
    }
27
28
    /**
29
     * @throws \Mrcnpdlk\Api\Unoconv\Exception
30
     * @throws \Mrcnpdlk\Api\Unoconv\Exception\ConfigurationException
31
     * @throws \Mrcnpdlk\Api\Unoconv\Exception\InvalidFileArgumentException
32
     * @throws \Mrcnpdlk\Api\Unoconv\Exception\UnoconvException
33
     */
34
    public function testConstruct_invalid_1(): void
35
    {
36
        $this->expectException(UnoconvException::class);
37
        $config   = new Config([
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
38
            'binary' => '/some/binary/file',
39
        ]);
40
        $oApi     = new Api();
41
        $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'test.docx';
42
        file_put_contents($testFile, null);
43
        $oApi->transcode($testFile, FormatType::PDF());
44
        @unlink($testFile);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
45
    }
46
47
    /**
48
     * @throws \Mrcnpdlk\Api\Unoconv\Exception
49
     * @throws \Mrcnpdlk\Api\Unoconv\Exception\ConfigurationException
50
     * @throws \Mrcnpdlk\Api\Unoconv\Exception\InvalidFileArgumentException
51
     * @throws \Mrcnpdlk\Api\Unoconv\Exception\UnoconvException
52
     */
53
    public function testConstruct_invalid_2(): void
54
    {
55
        $this->expectException(InvalidFileArgumentException::class);
56
        $config   = new Config([
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
57
            'binary' => '/some/binary/file',
58
        ]);
59
        $oApi     = new Api();
60
        $oApi->transcode('foo_bar.test', FormatType::PDF());
61
    }
62
}
63