Skip to content

Commit

Permalink
[TEST] $this->assert* should be used
Browse files Browse the repository at this point in the history
  • Loading branch information
mhujer committed Aug 11, 2017
1 parent aef3821 commit 06debd9
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions tests/Elasticsearch/Tests/YamlRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,10 @@ public function checkForWarnings($expectedWarnings) {
}

// Check to make sure we're adding headers
static::assertArrayHasKey('Content-type', $last['request']['headers'], print_r($last['request']['headers'], true));
static::assertSame('application/json', $last['request']['headers']['Content-type'][0], print_r($last['request']['headers'], true));
static::assertArrayHasKey('Accept', $last['request']['headers'], print_r($last['request']['headers'], true));
static::assertSame('application/json', $last['request']['headers']['Accept'][0], print_r($last['request']['headers'], true));
$this->assertArrayHasKey('Content-type', $last['request']['headers'], print_r($last['request']['headers'], true));
$this->assertSame('application/json', $last['request']['headers']['Content-type'][0], print_r($last['request']['headers'], true));
$this->assertArrayHasKey('Accept', $last['request']['headers'], print_r($last['request']['headers'], true));
$this->assertSame('application/json', $last['request']['headers']['Accept'][0], print_r($last['request']['headers'], true));

}

Expand All @@ -479,7 +479,7 @@ public function operationIsFalse($operation, $lastOperationResult, &$context, $t
$msg = "Failed to assert that a value is false in test \"$testName\"\n"
."$operation was [".print_r($value, true)."]"
.var_export($lastOperationResult, true);
static::assertFalse($value, $msg);
$this->assertFalse($value, $msg);

return $lastOperationResult;
}
Expand All @@ -498,10 +498,10 @@ public function operationIsTrue($operation, $lastOperationResult, &$context, $te
$msg = "Failed to assert that a value is true in test \"$testName\"\n"
."$operation was [".print_r($value, true)."]"
.var_export($lastOperationResult, true);
static::assertNotEquals(0, $value, $msg);
static::assertNotFalse($value, $msg);
static::assertNotNull($value, $msg);
static::assertNotEquals('', $msg);
$this->assertNotEquals(0, $value, $msg);
$this->assertNotFalse($value, $msg);
$this->assertNotNull($value, $msg);
$this->assertNotEquals('', $msg);

return $lastOperationResult;
}
Expand Down Expand Up @@ -532,11 +532,11 @@ public function operationMatch($operation, $lastOperationResult, &$context, $tes
$expected = json_decode(json_encode($expected), true);
$match = json_decode(json_encode($match), true);

static::assertEquals($expected, $match, $msg);
$this->assertEquals($expected, $match, $msg);
} elseif (is_string($expected) && preg_match('#^/.+?/$#s', $expected)) {
static::assertRegExp($this->formatRegex($expected), $match, $msg);
$this->assertRegExp($this->formatRegex($expected), $match, $msg);
} else {
static::assertEquals($expected, $match, $msg);
$this->assertEquals($expected, $match, $msg);
}

return $lastOperationResult;
Expand All @@ -554,7 +554,7 @@ public function operationGreaterThanOrEqual($operation, $lastOperationResult, &$
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
$expected = current($operation);

static::assertGreaterThanOrEqual($expected, $value, 'Failed to gte in test ' . $testName);
$this->assertGreaterThanOrEqual($expected, $value, 'Failed to gte in test ' . $testName);

return $lastOperationResult;
}
Expand All @@ -571,7 +571,7 @@ public function operationGreaterThan($operation, $lastOperationResult, &$context
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
$expected = current($operation);

static::assertGreaterThan($expected, $value, 'Failed to gt in test ' . $testName);
$this->assertGreaterThan($expected, $value, 'Failed to gt in test ' . $testName);

return $lastOperationResult;
}
Expand All @@ -588,7 +588,7 @@ public function operationLessThanOrEqual($operation, $lastOperationResult, &$con
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
$expected = current($operation);

static::assertLessThanOrEqual($expected, $value, 'Failed to lte in test ' . $testName);
$this->assertLessThanOrEqual($expected, $value, 'Failed to lte in test ' . $testName);

return $lastOperationResult;
}
Expand All @@ -605,7 +605,7 @@ public function operationLessThan($operation, $lastOperationResult, &$context, $
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
$expected = current($operation);

static::assertLessThan($expected, $value, 'Failed to lt in test ' . $testName);
$this->assertLessThan($expected, $value, 'Failed to lt in test ' . $testName);

return $lastOperationResult;
}
Expand All @@ -622,7 +622,7 @@ public function operationLength($operation, $lastOperationResult, &$context, $te
$value = $this->resolveValue($lastOperationResult, key($operation), $context);
$expected = current($operation);

static::assertCount($expected, $value, 'Failed to gte in test ' . $testName);
$this->assertCount($expected, $value, 'Failed to gte in test ' . $testName);

return $lastOperationResult;
}
Expand Down Expand Up @@ -708,23 +708,23 @@ public function operationSkip($operation, $lastOperationResult, $testName)
private function assertException(\Exception $exception, $expectedError, $testName)
{
if (is_string($expectedError) && preg_match('#^/.+?/$#', $expectedError)) {
static::assertRegExp($expectedError, $exception->getMessage(), 'Failed to catch error in test ' . $testName);
$this->assertRegExp($expectedError, $exception->getMessage(), 'Failed to catch error in test ' . $testName);
} elseif ($exception instanceof Missing404Exception && $expectedError === 'missing') {
static::assertTrue(true);
$this->assertTrue(true);
} elseif ($exception instanceof Conflict409Exception && $expectedError === 'conflict') {
static::assertTrue(true);
$this->assertTrue(true);
} elseif ($exception instanceof Forbidden403Exception && $expectedError === 'forbidden') {
static::assertTrue(true);
$this->assertTrue(true);
} elseif ($exception instanceof RequestTimeout408Exception && $expectedError === 'request_timeout') {
static::assertTrue(true);
$this->assertTrue(true);
} elseif ($exception instanceof BadRequest400Exception && $expectedError === 'request') {
static::assertTrue(true);
$this->assertTrue(true);
} elseif ($exception instanceof ServerErrorResponseException && $expectedError === 'request') {
static::assertTrue(true);
$this->assertTrue(true);
} elseif ($exception instanceof \RuntimeException && $expectedError === 'param') {
static::assertTrue(true);
$this->assertTrue(true);
} else {
static::assertContains($expectedError, $exception->getMessage());
$this->assertContains($expectedError, $exception->getMessage());
}

if ($exception->getPrevious() !== null) {
Expand Down

0 comments on commit 06debd9

Please sign in to comment.