Skip to content

Commit

Permalink
Delete skipped tests non PHP 7 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoologic committed Nov 14, 2023
1 parent 339610d commit d83f028
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 107 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ services:
volumes:
- .:/app
- vendor:/app/vendor
command: vendor/bin/phpunit --testsuite "Zendesk API Unit Test Suites"
# command: vendor/bin/phpunit --testsuite "Zendesk API Unit Test Suites"
# command: vendor/bin/phpunit --testdox --testsuite "Zendesk API Unit Test Suites"
# command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Traits/Utility/PaginationIteratorTest.php
# command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Core/TicketsTest.php
# command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Core/TagsTest.php
command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Exceptions/ApiResponseExceptionTest.php

volumes:
vendor:
4 changes: 2 additions & 2 deletions src/Zendesk/API/Traits/Utility/Pagination/CbpStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function params()
* OBP: https://{subdomain}.zendesk.com/api/v2/tickets?sort_order=desc&sort_by=updated_at&per_page=2
* CBP: https://{subdomain}.zendesk.com/api/v2/tickets?sort=-updated_at&page[size]=2
*
* @return array all params with CBP sorting order
* @return array Params with proper CBP sorting order
*/
private function sortParams()
{
Expand All @@ -58,7 +58,7 @@ private function sortParams()
* The params that are needed to for pagination (eg: ["page[size]" => "100"])
* If OBP params are passed, they are converted to CBP
*
* @return array all params with CBP sorting order
* @return array Params for pagination
*/
private function paginationParams()
{
Expand Down
5 changes: 0 additions & 5 deletions src/Zendesk/API/Traits/Utility/Pagination/ObpStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@ public function page($getPageFn)
public function shouldGetPage($position) {
return $this->pageNumber == 0 || $position >= $this->pageNumber * $this->pageSize();
}
public function paramsWithPagination()
{
return ['page' => $this->pageNumber, 'per_page' => $this->pageSize()];

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class PaginationIterator implements Iterator
private $items = [];

/**
*
* @param mixed using trait FindAll. The resources collection, Eg: `$client->tickets()` which uses FindAll
* @param AbstractStrategy $strategy For pagination Logic (OBP, CBP, SinglePage)
* @param string $method used to make the API call
Expand Down
33 changes: 0 additions & 33 deletions tests/Zendesk/API/UnitTests/Core/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace Zendesk\API\UnitTests\Core;

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Zendesk\API\Http;
use Zendesk\API\HttpClient;
use Zendesk\API\UnitTests\BasicTest;
use Zendesk\API\Utilities\Auth;

Expand All @@ -15,35 +11,6 @@
*/
class AuthTest extends BasicTest
{
/**
* Test if request is still sent even without authentication
*/
public function testAnonymousAccess()
{
$this->markTestSkipped('Broken in PHP 7.4 (mocking)');

// mock client
$client = $this
->getMockBuilder(HttpClient::class)
->disableOriginalConstructor()
->getMock();
$client->method('getHeaders')->willReturn([]);
$client->expects(self::once())->method('getAuth')->willReturn(null);

// prepareRequest should not be called
$auth = $this
->getMockBuilder(Auth::class)
->disableOriginalConstructor()
->getMock();
$auth->expects(self::never())->method('prepareRequest');
$client->expects(self::once())->method('getAuth')->willReturn($auth);

// send request
$client->guzzle = $this->getMockBuilder(Client::class)->getMock();
$client->guzzle->method('send')->willReturn(new Response(200, [], ''));
Http::send($client, '');
}

/**
* Test the preparing of a request for basic authentication.
*/
Expand Down
24 changes: 10 additions & 14 deletions tests/Zendesk/API/UnitTests/Exceptions/ApiResponseExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@

namespace Zendesk\API\UnitTests\Exceptions;

use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\ServerException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Zendesk\API\UnitTests\BasicTest;
use Zendesk\API\Exceptions\ApiResponseException;

class ApiResponseExceptionTest extends BasicTest
{
/**
* Tests if previous exception was passed to ApiResponseException
*/
public function testPreviousException()
public function testServerException()
{
$this->markTestSkipped('Broken in PHP 7.4 (mocking)');
$request = new Request("GET","");
$response = new Response(200, ["Content-Type"=> "application/json"],"");
$requestException = new ServerException("test", $request, $response);

$message = 'The previous exception was not passed to ApiResponseException';
$mockException = $this
->getMockBuilder('GuzzleHttp\Exception\RequestException')
->disableOriginalConstructor()
->getMock();
$mockException->method('hasResponse')->willReturn(true);
$apiException = new ApiResponseException($mockException);
$previousException = $apiException->getPrevious();
$subject = new ApiResponseException($requestException);

$this->assertEquals($mockException, $previousException, $message);
$this->assertEquals([], $subject->getErrorDetails());
}
}
50 changes: 0 additions & 50 deletions tests/Zendesk/API/UnitTests/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,13 @@

namespace Zendesk\API\UnitTests;

use Exception;
use Faker\Factory;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Stream;
use Zendesk\API\Http;
use Zendesk\API\HttpClient;

class HttpTest extends BasicTest
{
/**
* Test that original request exception is preserved.
*/
public function testOriginalRequestExceptionIsPreserved()
{
$this->markTestSkipped('Broken in PHP 7.4 (mocking)');
$faker = Factory::create();

$exceptionMessage = $faker->sentence;
$exception = $this->mockRequestException($exceptionMessage);

$guzzleClient = $this->getMockBuilder(GuzzleClient::class)
->disableOriginalConstructor()
->getMock();
$guzzleClient->expects($this->once())
->method('send')
->will($this->throwException($exception));

$zendeskClient = $this->getMockBuilder(HttpClient::class)
->setConstructorArgs([
$faker->domainWord,
$faker->userName,
$faker->randomElement([
'https',
'http',
]),
$faker->domainName,
$faker->numberBetween(1),
$guzzleClient,
])
->getMock();

$zendeskClient->expects($this->once())
->method('getHeaders')
->will($this->returnValue([]));

try {
Http::send($zendeskClient, '/');
} catch (Exception $e) {
$originalException = $e->getPrevious()->getPrevious();
$this->assertNotNull($originalException);
$this->assertEquals($originalException->getMessage(), $exceptionMessage);
}
}

/**
* Create a mocked RequestExcpetion
*
Expand Down

0 comments on commit d83f028

Please sign in to comment.