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

DNDataArchiveTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 172
Duplicated Lines 42.44 %

Coupling/Cohesion

Components 1
Dependencies 5
Metric Value
wmc 10
lcom 1
cbo 5
dl 73
loc 172
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
B testArchivePermissions() 0 38 1
A testGenerateFilePath() 20 20 1
A testGenerateFileName() 19 19 1
B testCanMoveTo() 0 27 1
A testValidateArchiveContentsAll() 0 6 1
A testValidateArchiveContentsDB() 10 10 1
A testValidateArchiveContentsDBFails() 7 7 1
A testValidateArchiveContentsAssets() 10 10 1
A testValidateArchiveContentsAssetsFails() 7 7 1
A testValidateArchiveContentsFileMissingFails() 0 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
class DNDataArchiveTest 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...
4
5
	protected static $fixture_file = 'DNDataArchiveTest.yml';
6
7
	/**
8
	 * We check a number of different conditionals here (see DNDataArchiveTest.yml for relationships):
9
	 * - Samantha can upload to & download from project1:uat, but not project1:live
10
	 * - Sarah can upload to but not download from project1:uat, and can't do anything with project1:live
11
	 * - Neither Samantha nor Sarah can do anything with project2:uat or project2:live
12
	 */
13
	public function testArchivePermissions() {
14
		$project1 = $this->objFromFixture('DNProject', 'project1');
15
		$project2 = $this->objFromFixture('DNProject', 'project2');
16
17
		$samantha = $this->objFromFixture('Member', 'project1-samantha');
18
		$sarah = $this->objFromFixture('Member', 'project1-sarah');
19
20
		// Samantha can upload to & download from project1:uat, but not project1:live
21
		$this->assertTrue($project1->Environments()->filter('Name', 'uat')->First()->canUploadArchive($samantha));
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
22
		$this->assertTrue($project1->Environments()->filter('Name', 'uat')->First()->canDownloadArchive($samantha));
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
23
		$this->assertFalse($project1->Environments()->filter('Name', 'uat')->First()->canDeleteArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
24
		$this->assertFalse($project1->Environments()->filter('Name', 'live')->First()->canUploadArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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
		$this->assertFalse($project1->Environments()->filter('Name', 'live')->First()->canDownloadArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
26
		$this->assertFalse($project1->Environments()->filter('Name', 'live')->First()->canDeleteArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
27
28
		// Sarah can upload to but not download from project1:uat, and can't do anything with project1:live
29
		$this->assertTrue($project1->Environments()->filter('Name', 'uat')->First()->canUploadArchive($sarah));
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
30
		$this->assertFalse($project1->Environments()->filter('Name', 'uat')->First()->canDownloadArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
31
		$this->assertTrue($project1->Environments()->filter('Name', 'uat')->First()->canDeleteArchive($sarah));
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
32
		$this->assertTrue($project1->Environments()->filter('Name', 'live')->First()->canUploadArchive($sarah));
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
33
		$this->assertFalse($project1->Environments()->filter('Name', 'live')->First()->canDownloadArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
34
		$this->assertFalse($project1->Environments()->filter('Name', 'live')->First()->canDeleteArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
35
36
		// Neither Samantha nor Sarah can do anything with project2:uat or project2:live
37
		$this->assertFalse($project2->Environments()->filter('Name', 'uat')->First()->canUploadArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
38
		$this->assertFalse($project2->Environments()->filter('Name', 'uat')->First()->canDownloadArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
39
		$this->assertFalse($project2->Environments()->filter('Name', 'uat')->First()->canDeleteArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
40
		$this->assertFalse($project2->Environments()->filter('Name', 'live')->First()->canUploadArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
41
		$this->assertFalse($project2->Environments()->filter('Name', 'live')->First()->canDownloadArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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->assertFalse($project2->Environments()->filter('Name', 'live')->First()->canDeleteArchive($samantha));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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
44
		$this->assertFalse($project2->Environments()->filter('Name', 'uat')->First()->canUploadArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
45
		$this->assertFalse($project2->Environments()->filter('Name', 'uat')->First()->canDownloadArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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->assertFalse($project2->Environments()->filter('Name', 'uat')->First()->canDeleteArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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($project2->Environments()->filter('Name', 'live')->First()->canUploadArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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($project2->Environments()->filter('Name', 'live')->First()->canDownloadArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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
		$this->assertFalse($project2->Environments()->filter('Name', 'live')->First()->canDeleteArchive($sarah));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
50
	}
51
52 View Code Duplication
	public function testGenerateFilePath() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
		// SS_Datetime::mock_now('2010-01-01 23:23:23');
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
		$project1 = $this->objFromFixture('DNProject', 'project1');
0 ignored issues
show
Unused Code introduced by
$project1 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...
55
		$project1uatEnv = $this->objFromFixture('DNEnvironment', 'project1-uat');
56
57
		$dataTransfer = DNDataTransfer::create();
58
		$dataTransfer->Direction = 'get';
59
		$dataTransfer->Mode = 'all';
60
		$dataTransfer->write();
61
62
		$archive = DNDataArchive::create();
63
		$archive->OriginalEnvironmentID = $project1uatEnv->ID;
64
		$archive->write();
65
66
		$filepath1 = $archive->generateFilepath($dataTransfer);
67
		$this->assertNotNull($filepath1);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<DNDataArchiveTest>.

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->assertContains('project-1', $filepath1);
69
		$this->assertContains('uat', $filepath1);
70
		$this->assertContains('transfer-' . $dataTransfer->ID, $filepath1);
71
	}
72
73 View Code Duplication
	public function testGenerateFileName() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
		$project1 = $this->objFromFixture('DNProject', 'project1');
0 ignored issues
show
Unused Code introduced by
$project1 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...
75
		$project1uatEnv = $this->objFromFixture('DNEnvironment', 'project1-uat');
76
77
		$dataTransfer = DNDataTransfer::create();
78
		$dataTransfer->Direction = 'get';
79
		$dataTransfer->Mode = 'all';
80
		$dataTransfer->write();
81
82
		$archive = DNDataArchive::create();
83
		$archive->OriginalEnvironmentID = $project1uatEnv->ID;
84
		$archive->write();
85
86
		$filename = $archive->generateFilename($dataTransfer);
87
		$this->assertNotNull($filename);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<DNDataArchiveTest>.

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...
88
		$this->assertContains('project-1', $filename);
89
		$this->assertContains('uat', $filename);
90
		$this->assertContains('all', $filename);
91
	}
92
93
	public function testCanMoveTo() {
94
		$samantha = $this->objFromFixture('Member', 'project1-samantha');
95
		$sarah = $this->objFromFixture('Member', 'project1-sarah');
96
		$eva = $this->objFromFixture('Member', 'eva');
97
		$uat1 = $this->objFromFixture('DNEnvironment', 'project1-uat');
98
		$live1 = $this->objFromFixture('DNEnvironment', 'project1-live');
99
		$uat2 = $this->objFromFixture('DNEnvironment', 'project2-uat');
100
		$live2 = $this->objFromFixture('DNEnvironment', 'project2-live');
0 ignored issues
show
Unused Code introduced by
$live2 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...
101
102
		$archive = DNDataArchive::create();
103
		$archive->EnvironmentID = $uat1->ID;
104
		$archive->write();
105
106
		// Samantha doesn't have upload permission to live1.
107
		$this->assertFalse($archive->canMoveTo($live1, $samantha));
0 ignored issues
show
Documentation introduced by
$live1 is of type object<DataObject>|null, but the function expects a object<DNEnvironment>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Bug introduced by
It seems like $samantha defined by $this->objFromFixture('M...', 'project1-samantha') on line 94 can also be of type object<DataObject>; however, DNDataArchive::canMoveTo() 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<DNDataArchiveTest>.

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...
108
		// Cross-project moves are forbidden.
109
		$this->assertFalse($archive->canMoveTo($uat2, $samantha));
0 ignored issues
show
Documentation introduced by
$uat2 is of type object<DataObject>|null, but the function expects a object<DNEnvironment>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Bug introduced by
It seems like $samantha defined by $this->objFromFixture('M...', 'project1-samantha') on line 94 can also be of type object<DataObject>; however, DNDataArchive::canMoveTo() 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<DNDataArchiveTest>.

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...
110
111
		// Eva has upload permission to live1.
112
		$this->assertTrue($archive->canMoveTo($live1, $eva));
1 ignored issue
show
Documentation introduced by
$live1 is of type object<DataObject>|null, but the function expects a object<DNEnvironment>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Bug introduced by
It seems like $eva defined by $this->objFromFixture('Member', 'eva') on line 96 can also be of type object<DataObject>; however, DNDataArchive::canMoveTo() 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<DNDataArchiveTest>.

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...
113
		// Cross-project moves are forbidden.
114
		$this->assertFalse($archive->canMoveTo($uat2, $eva));
0 ignored issues
show
Documentation introduced by
$uat2 is of type object<DataObject>|null, but the function expects a object<DNEnvironment>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Bug introduced by
It seems like $eva defined by $this->objFromFixture('Member', 'eva') on line 96 can also be of type object<DataObject>; however, DNDataArchive::canMoveTo() 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<DNDataArchiveTest>.

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
116
		// Sarah has upload permission to live1, but not download to uat1.
117
		$this->assertFalse($archive->canMoveTo($live1, $sarah));
0 ignored issues
show
Documentation introduced by
$live1 is of type object<DataObject>|null, but the function expects a object<DNEnvironment>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Bug introduced by
It seems like $sarah defined by $this->objFromFixture('Member', 'project1-sarah') on line 95 can also be of type object<DataObject>; however, DNDataArchive::canMoveTo() 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<DNDataArchiveTest>.

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
	}
120
121
	public function testValidateArchiveContentsAll() {
122
		$archive = DNDataArchive::create();
123
		$archive->ArchiveFile()->Filename = __DIR__.'/sspaks/all.sspak';
124
		$result = $archive->validateArchiveContents('all');
125
		$this->assertTrue($result->valid());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
126
	}
127
128 View Code Duplication
	public function testValidateArchiveContentsDB() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
129
		$archive = DNDataArchive::create();
130
		$archive->ArchiveFile()->Filename = __DIR__.'/sspaks/all.sspak';
131
		$result = $archive->validateArchiveContents('db');
132
		$this->assertTrue($result->valid());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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
134
		$archive->ArchiveFile()->Filename = __DIR__.'/sspaks/db.sspak';
135
		$result = $archive->validateArchiveContents('db');
136
		$this->assertTrue($result->valid());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
137
	}
138
139 View Code Duplication
	public function testValidateArchiveContentsDBFails() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
140
		$archive = DNDataArchive::create();
141
		$archive->ArchiveFile()->Filename = __DIR__.'/sspaks/assets.sspak';
142
		$result = $archive->validateArchiveContents('db');
143
		$this->assertFalse($result->valid());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
144
		$this->assertEquals('The snapshot is missing the database.', current($result->messageList()));
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<DNDataArchiveTest>.

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...
145
	}
146
147 View Code Duplication
	public function testValidateArchiveContentsAssets() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
148
		$archive = DNDataArchive::create();
149
		$archive->ArchiveFile()->Filename = __DIR__.'/sspaks/all.sspak';
150
		$result = $archive->validateArchiveContents('assets');
151
		$this->assertTrue($result->valid());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
152
153
		$archive->ArchiveFile()->Filename = __DIR__.'/sspaks/assets.sspak';
154
		$result = $archive->validateArchiveContents('assets');
155
		$this->assertTrue($result->valid());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<DNDataArchiveTest>.

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...
156
	}
157
158 View Code Duplication
	public function testValidateArchiveContentsAssetsFails() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
159
		$archive = DNDataArchive::create();
160
		$archive->ArchiveFile()->Filename = __DIR__.'/sspaks/db.sspak';
161
		$result = $archive->validateArchiveContents('assets');
162
		$this->assertFalse($result->valid());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
163
		$this->assertEquals('The snapshot is missing assets.', current($result->messageList()));
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<DNDataArchiveTest>.

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...
164
	}
165
166
	public function testValidateArchiveContentsFileMissingFails() {
167
		$archive = DNDataArchive::create();
168
		$filename = __DIR__.'/sspaks/not.found.sspak';
169
		$archive->ArchiveFile()->Filename = $filename;
170
		$result = $archive->validateArchiveContents('all');
171
		$this->assertFalse($result->valid());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DNDataArchiveTest>.

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...
172
		$this->assertEquals('SSPak file "'.$filename.'" cannot be read.', current($result->messageList()));
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<DNDataArchiveTest>.

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...
173
	}
174
}
175