public function testConstraintArrayHasKey() { $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey(0); $this->assertFalse($constraint->evaluate(array())); $this->assertEquals('has key <integer:0>', $constraint->toString()); try { $constraint->fail(array(), ''); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals("Failed asserting that \nArray\n(\n)\n has key <integer:0>.", $e->getDescription()); return; } $this->fail(); }
protected function assertGuzzleRequestFormFieldValueEquals($field, $expected) { $fields = $this->assertGuzzleRequest()->getPostFields()->toArray(); if (empty($fields)) { throw new \PHPUnit_Framework_ExpectationFailedException("No form data in request"); } $constraint = new \PHPUnit_Framework_Constraint_ArrayHasKey($field); $constraint->evaluate($fields, "Form data has no field " . $field); $constraint = new \PHPUnit_Framework_Constraint_IsEqual($expected); $actual = $fields[$field]; $constraint->evaluate($actual, sprintf("Value for form field \"%s\" of \"%s\" is not equal to \"%s\"", $field, $expected, $actual)); }