Skip to content

Commit

Permalink
CAS-6994: Fix phpunit deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
afterdesign committed May 27, 2021
1 parent e13e1ba commit abeee66
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 39 deletions.
2 changes: 1 addition & 1 deletion test/CastleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setUp(): void

public function testSetApiKey()
{
$this->assertContains('secretkey', Castle::getApiKey());
$this->assertEquals('secretkey', Castle::getApiKey());
}

public function testTrack()
Expand Down
30 changes: 12 additions & 18 deletions test/ErrorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,51 @@ public function setUp(): void
$this->request = new Castle_Request();
}

/**
* @expectedException Castle_BadRequest
*/
public function testBadRequest()
{
Castle_RequestTransport::setResponse(400);

$this->expectException(Castle_BadRequest::class);
$this->request->send('GET', '/test');
}

/**
* @expectedException Castle_UnauthorizedError
*/
public function testUnauthorized()
{
Castle_RequestTransport::setResponse(401);

$this->expectException(Castle_UnauthorizedError::class);
$this->request->send('GET', '/test');
}

/**
* @expectedException Castle_ForbiddenError
*/
public function testForbidden()
{
Castle_RequestTransport::setResponse(403);

$this->expectException(Castle_ForbiddenError::class);
$this->request->send('GET', '/test');
}

/**
* @expectedException Castle_NotFoundError
*/
public function testNotFound()
{
Castle_RequestTransport::setResponse(404);

$this->expectException(Castle_NotFoundError::class);
$this->request->send('GET', '/test');
}

/**
* @expectedException Castle_InvalidParametersError
*/
public function testInvalidParameters()
{
Castle_RequestTransport::setResponse(422);

$this->expectException(Castle_InvalidParametersError::class);
$this->request->send('GET', '/test');
}

/**
* @expectedException Castle_ConfigurationError
*/
public function testConfiguration()
{
Castle::setApiKey(null);

$this->expectException(Castle_ConfigurationError::class);
$this->request->send('GET', '/test');
}
}
30 changes: 10 additions & 20 deletions test/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public function tearDown(): void
Castle_RequestTransport::setResponse();
}

/**
* @expectedException Castle_CurlOptionError
*/
public function testCastleCurlOptions()
{
// Will not throw.
Expand All @@ -34,58 +31,51 @@ public function testCastleCurlOptions()
CURLOPT_TIMEOUT => 1,
CURLOPT_TIMEOUT_MS => 1000));
// Will throw.
$this->expectException(Castle_CurlOptionError::class);
Castle::setCurlOpts(array(CURLOPT_USERAGENT => "BadBrowser/6.6.6b"));
}



/**
* @expectedException Castle_ApiError
*/
public function testInvalidResponse()
{
Castle_RequestTransport::setResponse(200, '{invalid');
$req = new Castle_Request();

$this->expectException(Castle_ApiError::class);
$req->send('GET', '/users');
}

/**
* @expectedException Castle_ApiError
*/
public function testApiErrorRequest()
{
Castle_RequestTransport::setResponse(500);
$req = new Castle_Request();

$this->expectException(Castle_ApiError::class);
$req->send('GET', '/users');
}

/**
* @expectedException Castle_UnauthorizedError
*/
public function testUnauthorizedRequest()
{
Castle_RequestTransport::setResponse(401);
$req = new Castle_Request();

$this->expectException(Castle_UnauthorizedError::class);
$req->send('GET', '/users');
}

/**
* @expectedException Castle_ForbiddenError
*/
public function testForbiddenRequest()
{
Castle_RequestTransport::setResponse(403);
$req = new Castle_Request();

$this->expectException(Castle_ForbiddenError::class);
$req->send('GET', '/users');
}

/**
* @expectedException Castle_InvalidParametersError
*/
public function testInvalidParametersRequest()
{
Castle_RequestTransport::setResponse(422);
$req = new Castle_Request();
$this->expectException(Castle_InvalidParametersError::class);
$req->send('GET', '/users');
}
}

0 comments on commit abeee66

Please sign in to comment.