GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Zookal_Mock_Test_Config_SystemTest::getFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * @category    Zookal_Mock
5
 * @package     Helper
6
 * @author      Cyrill Schumacher | {firstName}@{lastName}.fm | @SchumacherFM
7
 * @copyright   Copyright (c) Zookal Pty Ltd
8
 * @license     OSL - Open Software Licence 3.0 | http://opensource.org/licenses/osl-3.0.php
9
 */
10
class Zookal_Mock_Test_Config_SystemTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    /**
13
     * @return string
14
     */
15
    protected function getFile()
16
    {
17
        $dir = Mage::getModuleDir('etc', 'Zookal_Mock');
18
        return "$dir/system.xml";
19
    }
20
21
    protected function getXml()
22
    {
23
        $file = $this->getFile();
24
        $xml  = simplexml_load_file($file);
25
        return $xml;
26
    }
27
28
    /**
29
     * @param string $path
30
     */
31
    public function assertFieldDefined($path, $message = '')
32
    {
33
        $defaultMessage = '';
34
        @list($section, $group, $field) = explode('/', $path);
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...
35
        $nodePath = "sections/$section/groups/$group/fields/$field";
36
        $result   = $this->getXml()->xpath($nodePath);
37
        if (!$message) {
38
            $defaultMessage = sprintf("System configuration field \"$path\" not defined");
39
        }
40
        if (!$result) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $result of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
41
            $this->fail($message ? : $defaultMessage);
42
        }
43
    }
44
45
    /**
46
     * @test
47
     */
48
    public function itShouldHaveASystemXml()
49
    {
50
        $this->assertFileExists($this->getFile());
51
    }
52
53
    /**
54
     * @test
55
     */
56
    public function itShouldHaveAnApiUrlField()
57
    {
58
        $this->assertFieldDefined('dev/zookalmock/enable_method_log');
59
    }
60
}