Skip to content

Commit e2a891a

Browse files
committed
Make sure success responses never have errors in them.
1 parent f9b54b4 commit e2a891a

File tree

80 files changed

+119
-35
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+119
-35
lines changed

test/Field/Auth/LoginFieldTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testLoginSuccess()
3232
}";
3333
$res = self::execute($query);
3434
assertEquals(200, $res->data->login->statusCode, 'Unable to login via GraphQL');
35-
assertFalse(isset($res->errors), 'There are errors.');
35+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
3636
}
3737

3838
public function testLoginFailure()
@@ -47,7 +47,7 @@ public function testLoginFailure()
4747
}";
4848
$res = self::execute($query);
4949
assertEquals(401, $res->data->login->statusCode, 'Unable to login via GraphQL');
50-
assertFalse(isset($res->errors), 'There are errors.');
50+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
5151
}
5252

5353
}

test/Field/Auth/LogoutFieldTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function testLogout()
2626
}';
2727
$res = self::execute($query);
2828
assertEquals(200, $res->data->logout->statusCode, 'Unable to logout via GraphQL');
29+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
2930
}
3031

3132
public function testLogoutFailure()

test/Field/Debug/DbQueryCountFieldTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function testUnavailable()
2929
}';
3030
$res = self::execute($query);
3131
assertObjectHasAttribute('errors', $res, 'When debug turned off, `dbQueryCount` field must be unavailable.');
32+
assertStringContainsString('dbQuery', $res->errors[0]->message, 'Incorrect error message.');
3233
}
3334

3435
public function testValue()
@@ -39,6 +40,7 @@ public function testValue()
3940
}';
4041
$res = self::execute($query);
4142
assertEquals(count(\ProcessWire\Database::getQueryLog()), count($res->data->dbQuery), '`dbQueryCount` must return the number of db query logs');
43+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
4244
}
4345

4446
}

test/Field/Mutation/CreatePage/CaseThreeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function testValue()
3737
$res = self::execute($query, $variables);
3838
$newBuildingSky = Utils::pages()->get("name=created-building-sky");
3939
assertEquals($variables['page']['name'], $res->data->skyscraper->name, 'createSkyscraper returns correct values in response.');
40-
assertEquals($newBuildingSky->id, $res->data->skyscraper->id, 'createSkyscraper creates skyscraper page if everything is ok.');
40+
assertEquals($newBuildingSky->id, $res->data->skyscraper->id, 'createSkyscraper creates skyscraper page if everything is ok.');
41+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
4142
}
4243
}

test/Field/Mutation/UpdatePage/CaseThreeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function testValue()
4343
];
4444
$res = self::execute($query, $variables);
4545
assertEquals($variables['page']['title'], $res->data->skyscraper->title, 'updateSkyscraper returns updated value of the `title`.');
46-
assertEquals($variables['page']['title'], $skyscraper->title, 'updateSkyscraper updates value of the `title`.');
46+
assertEquals($variables['page']['title'], $skyscraper->title, 'updateSkyscraper updates value of the `title`.');
47+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
4748
}
4849

4950
}

test/Field/Page/Fieldtype/FieldtypeCheckbox/FieldtypeCheckboxTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function testFalsyValue()
4444
}";
4545
$res = $this->execute($query);
4646
assertTrue($res->data->skyscraper->list[0]->featured);
47+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
4748
}
4849

4950
}

test/Field/Page/Fieldtype/FieldtypeDatetime/CaseOneTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function testValue()
3535
}";
3636
$res = self::execute($query);
3737
assertEquals($architect->born, $res->data->architect->list[0]->born, 'Retrieves datetime value.');
38+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
3839
}
3940

4041
}

test/Field/Page/Fieldtype/FieldtypeDatetime/CaseThreeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function testValue()
4040
$res->data->architect->list[0]->born,
4141
'Formats datetime value correctly via format argument.'
4242
);
43+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
4344
}
4445

4546
}

test/Field/Page/Fieldtype/FieldtypeDatetime/CaseTwoTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function testValue()
4444
$res->data->architect->list[0]->born,
4545
'Retrieves correctly formatted datetime value.'
4646
);
47+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
4748
}
4849

4950
}

test/Field/Page/Fieldtype/FieldtypeEmail/FieldtypeEmailTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testValue()
2929
}
3030
}";
3131
$res = self::execute($query);
32-
assertEquals($architect->email, $res->data->architect->list[0]->email, 'Retrieves email value.');
32+
assertEquals($architect->email, $res->data->architect->list[0]->email, 'Retrieves email value.');
33+
assertObjectNotHasAttribute('errors', $res, 'There are errors.');
3334
}
3435

3536
}

0 commit comments

Comments
 (0)