Completed
Pull Request — master (#513)
by Helpful
04:05
created

DNEnvironmentTest::testAllows()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 13
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 */
5
class DNEnvironmentTest extends DeploynautTest {
1 ignored issue
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...
6
	/**
7
	 * @var string
8
	 */
9
	protected static $fixture_file = 'DNEnvironmentTest.yml';
10
11
	/**
12
	 * @return DNEnvironment
0 ignored issues
show
Documentation introduced by
Should the return type not be DNEnvironment|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
13
	 */
14
	protected function getEnvironment() {
15
		return $this->objFromFixture('DNEnvironment', 'uat');
16
	}
17
18
	/**
19
	 *
20
	 */
21
	public function testGetConfigFilename() {
22
		$environment = $this->getEnvironment();
23
		$expected = $this->envPath . '/testproject/uat.rb';
24
		$this->assertEquals($expected, $environment->getConfigFilename());
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
	}
26
27
	public function testPermissions() {
28
		$environment = $this->getEnvironment();
29
30
		// Check deployer / restorer permissions
31
		$viewer = $this->objFromFixture('Member', 'viewer');
32
		$viewerbygroup = $this->objFromFixture('Member', 'viewerbygroup');
33
		$deployer = $this->objFromFixture('Member', 'deployer');
34
		$deployerbygroup = $this->objFromFixture('Member', 'deployerbygroup');
35
		$restorer = $this->objFromFixture('Member', 'restorer');
36
		$restorerbygroup = $this->objFromFixture('Member', 'restorerbygroup');
37
38
		$random = new Member(array('Email' => '[email protected]'));
39
		$random->write();
40
41
		$this->assertFalse($environment->canView($random));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
		$this->assertTrue($environment->canView($viewer));
1 ignored issue
show
Bug introduced by
It seems like $viewer defined by $this->objFromFixture('Member', 'viewer') on line 31 can also be of type object<DataObject>; however, DNEnvironment::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
		$this->assertTrue($environment->canView($viewerbygroup));
1 ignored issue
show
Bug introduced by
It seems like $viewerbygroup defined by $this->objFromFixture('Member', 'viewerbygroup') on line 32 can also be of type object<DataObject>; however, DNEnvironment::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
45
		$this->assertTrue($environment->canDeploy($deployer));
1 ignored issue
show
Bug introduced by
It seems like $deployer defined by $this->objFromFixture('Member', 'deployer') on line 33 can also be of type object<DataObject>; however, DNEnvironment::canDeploy() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
		$this->assertTrue($environment->canDeploy($deployerbygroup));
1 ignored issue
show
Bug introduced by
It seems like $deployerbygroup defined by $this->objFromFixture('M...er', 'deployerbygroup') on line 34 can also be of type object<DataObject>; however, DNEnvironment::canDeploy() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
		$this->assertFalse($environment->canDeploy($restorer));
0 ignored issues
show
Bug introduced by
It seems like $restorer defined by $this->objFromFixture('Member', 'restorer') on line 35 can also be of type object<DataObject>; however, DNEnvironment::canDeploy() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
		$this->assertFalse($environment->canDeploy($restorerbygroup));
0 ignored issues
show
Bug introduced by
It seems like $restorerbygroup defined by $this->objFromFixture('M...er', 'restorerbygroup') on line 36 can also be of type object<DataObject>; however, DNEnvironment::canDeploy() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
50
		$this->assertFalse($environment->canRestore($deployer));
0 ignored issues
show
Bug introduced by
It seems like $deployer defined by $this->objFromFixture('Member', 'deployer') on line 33 can also be of type object<DataObject>; however, DNEnvironment::canRestore() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
		$this->assertFalse($environment->canRestore($deployerbygroup));
0 ignored issues
show
Bug introduced by
It seems like $deployerbygroup defined by $this->objFromFixture('M...er', 'deployerbygroup') on line 34 can also be of type object<DataObject>; however, DNEnvironment::canRestore() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
		$this->assertTrue($environment->canRestore($restorer));
1 ignored issue
show
Bug introduced by
It seems like $restorer defined by $this->objFromFixture('Member', 'restorer') on line 35 can also be of type object<DataObject>; however, DNEnvironment::canRestore() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
		$this->assertTrue($environment->canRestore($restorerbygroup));
1 ignored issue
show
Bug introduced by
It seems like $restorerbygroup defined by $this->objFromFixture('M...er', 'restorerbygroup') on line 36 can also be of type object<DataObject>; however, DNEnvironment::canRestore() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
55
		// Check backup / uploader permissions
56
		$backup = $this->objFromFixture('Member', 'backup');
57
		$backupbygroup = $this->objFromFixture('Member', 'backupbygroup');
58
		$uploader = $this->objFromFixture('Member', 'uploader');
59
		$uploaderbygroup = $this->objFromFixture('Member', 'uploaderbygroup');
60
61
		$this->assertTrue($environment->canBackup($backup));
1 ignored issue
show
Bug introduced by
It seems like $backup defined by $this->objFromFixture('Member', 'backup') on line 56 can also be of type object<DataObject>; however, DNEnvironment::canBackup() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
62
		$this->assertTrue($environment->canBackup($backupbygroup));
1 ignored issue
show
Bug introduced by
It seems like $backupbygroup defined by $this->objFromFixture('Member', 'backupbygroup') on line 57 can also be of type object<DataObject>; however, DNEnvironment::canBackup() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
		$this->assertFalse($environment->canBackup($uploader));
0 ignored issues
show
Bug introduced by
It seems like $uploader defined by $this->objFromFixture('Member', 'uploader') on line 58 can also be of type object<DataObject>; however, DNEnvironment::canBackup() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
		$this->assertFalse($environment->canBackup($uploaderbygroup));
0 ignored issues
show
Bug introduced by
It seems like $uploaderbygroup defined by $this->objFromFixture('M...er', 'uploaderbygroup') on line 59 can also be of type object<DataObject>; however, DNEnvironment::canBackup() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
65
66
		$this->assertFalse($environment->canUploadArchive($backup));
0 ignored issues
show
Bug introduced by
It seems like $backup defined by $this->objFromFixture('Member', 'backup') on line 56 can also be of type object<DataObject>; however, DNEnvironment::canUploadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
		$this->assertFalse($environment->canUploadArchive($backupbygroup));
0 ignored issues
show
Bug introduced by
It seems like $backupbygroup defined by $this->objFromFixture('Member', 'backupbygroup') on line 57 can also be of type object<DataObject>; however, DNEnvironment::canUploadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68
		$this->assertTrue($environment->canUploadArchive($uploader));
1 ignored issue
show
Bug introduced by
It seems like $uploader defined by $this->objFromFixture('Member', 'uploader') on line 58 can also be of type object<DataObject>; however, DNEnvironment::canUploadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
		$this->assertTrue($environment->canUploadArchive($uploaderbygroup));
1 ignored issue
show
Bug introduced by
It seems like $uploaderbygroup defined by $this->objFromFixture('M...er', 'uploaderbygroup') on line 59 can also be of type object<DataObject>; however, DNEnvironment::canUploadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
71
		// Check downloader / deleters permissions
72
		$downloader = $this->objFromFixture('Member', 'downloader');
73
		$downloaderbygroup = $this->objFromFixture('Member', 'downloaderbygroup');
74
		$deleter = $this->objFromFixture('Member', 'deleter');
75
		$deleterbygroup = $this->objFromFixture('Member', 'deleterbygroup');
76
77
		$this->assertTrue($environment->canDownloadArchive($downloader));
1 ignored issue
show
Bug introduced by
It seems like $downloader defined by $this->objFromFixture('Member', 'downloader') on line 72 can also be of type object<DataObject>; however, DNEnvironment::canDownloadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
78
		$this->assertTrue($environment->canDownloadArchive($downloaderbygroup));
1 ignored issue
show
Bug introduced by
It seems like $downloaderbygroup defined by $this->objFromFixture('M...', 'downloaderbygroup') on line 73 can also be of type object<DataObject>; however, DNEnvironment::canDownloadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
		$this->assertFalse($environment->canDownloadArchive($deleter));
0 ignored issues
show
Bug introduced by
It seems like $deleter defined by $this->objFromFixture('Member', 'deleter') on line 74 can also be of type object<DataObject>; however, DNEnvironment::canDownloadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
80
		$this->assertFalse($environment->canDownloadArchive($deleterbygroup));
0 ignored issues
show
Bug introduced by
It seems like $deleterbygroup defined by $this->objFromFixture('Member', 'deleterbygroup') on line 75 can also be of type object<DataObject>; however, DNEnvironment::canDownloadArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
81
82
		$this->assertFalse($environment->canDeleteArchive($downloader));
0 ignored issues
show
Bug introduced by
It seems like $downloader defined by $this->objFromFixture('Member', 'downloader') on line 72 can also be of type object<DataObject>; however, DNEnvironment::canDeleteArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
83
		$this->assertFalse($environment->canDeleteArchive($downloaderbygroup));
0 ignored issues
show
Bug introduced by
It seems like $downloaderbygroup defined by $this->objFromFixture('M...', 'downloaderbygroup') on line 73 can also be of type object<DataObject>; however, DNEnvironment::canDeleteArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84
		$this->assertTrue($environment->canDeleteArchive($deleter));
1 ignored issue
show
Bug introduced by
It seems like $deleter defined by $this->objFromFixture('Member', 'deleter') on line 74 can also be of type object<DataObject>; however, DNEnvironment::canDeleteArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
85
		$this->assertTrue($environment->canDeleteArchive($deleterbygroup));
1 ignored issue
show
Bug introduced by
It seems like $deleterbygroup defined by $this->objFromFixture('Member', 'deleterbygroup') on line 75 can also be of type object<DataObject>; however, DNEnvironment::canDeleteArchive() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
86
87
		// Pipeline permissions
88
		$approver = $this->objFromFixture('Member', 'approver');
89
		$approverbygroup = $this->objFromFixture('Member', 'approverbygroup');
90
		$canceller = $this->objFromFixture('Member', 'canceller');
91
		$cancellerbygroup = $this->objFromFixture('Member', 'cancellerbygroup');
92
93
		$this->assertTrue($environment->canApprove($approver));
1 ignored issue
show
Bug introduced by
It seems like $approver defined by $this->objFromFixture('Member', 'approver') on line 88 can also be of type object<DataObject>; however, DNEnvironment::canApprove() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
94
		$this->assertTrue($environment->canApprove($approverbygroup));
1 ignored issue
show
Bug introduced by
It seems like $approverbygroup defined by $this->objFromFixture('M...er', 'approverbygroup') on line 89 can also be of type object<DataObject>; however, DNEnvironment::canApprove() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
95
		$this->assertFalse($environment->canApprove($canceller));
0 ignored issues
show
Bug introduced by
It seems like $canceller defined by $this->objFromFixture('Member', 'canceller') on line 90 can also be of type object<DataObject>; however, DNEnvironment::canApprove() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
96
		$this->assertFalse($environment->canApprove($cancellerbygroup));
0 ignored issues
show
Bug introduced by
It seems like $cancellerbygroup defined by $this->objFromFixture('M...r', 'cancellerbygroup') on line 91 can also be of type object<DataObject>; however, DNEnvironment::canApprove() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
97
98
		$this->assertFalse($environment->canAbort($approver));
0 ignored issues
show
Bug introduced by
It seems like $approver defined by $this->objFromFixture('Member', 'approver') on line 88 can also be of type object<DataObject>; however, DNEnvironment::canAbort() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
99
		$this->assertFalse($environment->canAbort($approverbygroup));
0 ignored issues
show
Bug introduced by
It seems like $approverbygroup defined by $this->objFromFixture('M...er', 'approverbygroup') on line 89 can also be of type object<DataObject>; however, DNEnvironment::canAbort() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
100
		$this->assertTrue($environment->canAbort($canceller));
1 ignored issue
show
Bug introduced by
It seems like $canceller defined by $this->objFromFixture('Member', 'canceller') on line 90 can also be of type object<DataObject>; however, DNEnvironment::canAbort() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
101
		$this->assertTrue($environment->canAbort($cancellerbygroup));
1 ignored issue
show
Bug introduced by
It seems like $cancellerbygroup defined by $this->objFromFixture('M...r', 'cancellerbygroup') on line 91 can also be of type object<DataObject>; however, DNEnvironment::canAbort() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
102
	}
103
104
	private function checkSnapshots($assert, $env, $member) {
105
		$this->$assert($env->canRestore($member));
106
		$this->$assert($env->canBackup($member));
107
		$this->$assert($env->canDownloadArchive($member));
108
		$this->$assert($env->canDeleteArchive($member));
109
	}
110
111
	public function testAllows() {
112
		$prod = $this->objFromFixture('DNEnvironment', 'allowtest-prod');
113
		$uat = $this->objFromFixture('DNEnvironment', 'allowtest-uat');
114
		$this->assertTrue($prod->canDeploy($this->objFromFixture('Member', 'allowProdDeployment')));
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
115
		$this->assertFalse($prod->canDeploy($this->objFromFixture('Member', 'allowNonProdDeployment')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
116
		$this->assertFalse($uat->canDeploy($this->objFromFixture('Member', 'allowProdDeployment')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
117
		$this->assertTrue($uat->canDeploy($this->objFromFixture('Member', 'allowNonProdDeployment')));
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
118
119
		$this->checkSnapshots('assertTrue', $prod, $this->objFromFixture('Member', 'allowProdSnapshot'));
120
		$this->checkSnapshots('assertFalse', $prod, $this->objFromFixture('Member', 'allowNonProdSnapshot'));
121
		$this->checkSnapshots('assertFalse', $uat, $this->objFromFixture('Member', 'allowProdSnapshot'));
122
		$this->checkSnapshots('assertTrue', $uat, $this->objFromFixture('Member', 'allowNonProdSnapshot'));
123
	}
124
125
	public function testViewerPermissionInheritedFromProjectIfNotConfigured() {
126
		$environment = $this->objFromFixture('DNEnvironment', 'dev');
127
		$viewerbygroup = $this->objFromFixture('Member', 'viewerbygroup');
128
129
		$random = new Member(array('Email' => '[email protected]'));
130
		$random->write();
131
132
		$this->assertFalse($environment->canView($random));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
133
		$this->assertTrue($environment->canView($viewerbygroup));
1 ignored issue
show
Bug introduced by
It seems like $viewerbygroup defined by $this->objFromFixture('Member', 'viewerbygroup') on line 127 can also be of type object<DataObject>; however, DataObject::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
134
	}
135
136
	public function testBackendIdentifierField() {
137
		// Two backends means that there will be a dropdown field
138
		$backends = array(
139
			'BackendOne' => 'One',
140
			'BackendTwo' => 'Two',
141
		);
142
143
		Config::inst()->remove('DNEnvironment', 'allowed_backends');
144
		Config::inst()->update('DNEnvironment', 'allowed_backends', $backends);
145
146
		$environment = $this->objFromFixture('DNEnvironment', 'dev');
147
		$fields = $environment->getCMSFields();
148
		$this->assertEquals($backends, $fields->dataFieldByName('BackendIdentifier')->getSource());
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
149
150
151
		// One backend means that there won't
152
		Config::inst()->remove('DNEnvironment', 'allowed_backends');
153
		Config::inst()->update('DNEnvironment', 'allowed_backends', array('BackendOne' => 'One'));
154
155
		$fields = $environment->getCMSFields();
156
		$this->assertNull($fields->dataFieldByName('BackendIdentifier'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<DNEnvironmentTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
157
	}
158
}
159
160
class BackendOne extends DemoDeploymentBackend implements TestOnly {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
161
162
}
163
164
class BackendTwo extends DemoDeploymentBackend implements TestOnly  {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
165
166
}
167
168