YetiForceCompany/YetiForceCRM

View on GitHub
tests/App/Zip.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using static access to class '\App\Zip' in method 'testInstanceOpenNoFileName'.
Open

        \App\Zip::openFile(false);
Severity: Minor
Found in tests/App/Zip.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Zip' in method 'testExtractLinuxFile'.
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
Severity: Minor
Found in tests/App/Zip.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Zip' in method 'testCreateFileBadDir'.
Open

        $zip = \App\Zip::createFile(ROOT_DIRECTORY . '/tests/data/NxDir/NxFile.zip');
Severity: Minor
Found in tests/App/Zip.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Zip' in method 'testUnzipLinuxFile'.
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
Severity: Minor
Found in tests/App/Zip.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Zip' in method 'testInstanceOpenLinuxFile'.
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
Severity: Minor
Found in tests/App/Zip.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\vtlib\Functions' in method 'testExtractLinuxFile'.
Open

        \vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
Severity: Minor
Found in tests/App/Zip.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\vtlib\Functions' in method 'testUnzipLinuxFile'.
Open

        \vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
Severity: Minor
Found in tests/App/Zip.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Define a constant instead of duplicating this literal "tests/data/TestLinux.zip" 3 times.
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
Severity: Critical
Found in tests/App/Zip.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Argument 1 (fileName) is 'tests/data/TestLinux.zip' but \App\Zip::openFile() takes bool|false defined at /code/app/Zip.php:51
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
Severity: Minor
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::assertFileExists
Open

        $this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
Severity: Critical
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::assertFalse
Open

        $this->assertFalse($zip->close());
Severity: Critical
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::expectException
Open

        $this->expectException(\App\Exceptions\AppException::class);
Severity: Critical
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::assertFileExists
Open

        $this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
Severity: Critical
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::assertInstanceOf
Open

        $this->assertInstanceOf('\App\Zip', $instanceOpen, 'Expected zip object instance');
Severity: Critical
Found in tests/App/Zip.php by phan

Argument 1 (fileName) is 'tests/data/TestLinux.zip' but \App\Zip::openFile() takes bool|false defined at /code/app/Zip.php:51
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
Severity: Minor
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::expectException
Open

        $this->expectException(\App\Exceptions\AppException::class);
Severity: Critical
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::expectWarning
Open

        $this->expectWarning();
Severity: Critical
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::assertFileExists
Open

        $this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
Severity: Critical
Found in tests/App/Zip.php by phan

Argument 1 (fileName) is 'tests/data/NxFile.zip' but \App\Zip::openFile() takes bool|false defined at /code/app/Zip.php:51
Open

        \App\Zip::openFile('tests/data/NxFile.zip')->close();
Severity: Minor
Found in tests/App/Zip.php by phan

Argument 1 (fileName) is 'tests/data/TestLinux.zip' but \App\Zip::openFile() takes bool|false defined at /code/app/Zip.php:51
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
Severity: Minor
Found in tests/App/Zip.php by phan

Call to undeclared method \Tests\App\Zip::assertFileExists
Open

        $this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
Severity: Critical
Found in tests/App/Zip.php by phan

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing instance from linux generated zip file.
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testUnzipLinuxFile(): void
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testExtractLinuxFile(): void
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertInstanceOf('\App\Zip', $instanceOpen, 'Expected zip object instance');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing linux file extract.
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $instanceOpen->extract('tests/tmp/TestLinux/');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing file creation in not existent directory.
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $zip->addFromString('filename.txt', '<minimal content>');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing linux file unzip.
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testInstanceOpenNoFileName(): void
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing instance from not existing file.
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testInstanceOpenLinuxFile(): void
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $instanceOpen->unzip('tests/tmp/TestLinux/');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Zip::openFile(false);
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->expectException(\App\Exceptions\AppException::class);
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testCreateFileBadDir(): void
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Zip::openFile('tests/data/NxFile.zip')->close();
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testInstanceOpenFileNotExists(): void
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $zip = \App\Zip::createFile(ROOT_DIRECTORY . '/tests/data/NxDir/NxFile.zip');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing instance from file with no file name provided.
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->expectException(\App\Exceptions\AppException::class);
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertFalse($zip->close());
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->expectWarning();
Severity: Minor
Found in tests/App/Zip.php by phpcodesniffer

There are no issues that match your filters.

Category
Status