Skip to content

Commit

Permalink
LCH-6061: Fix deprecations for symfony 3.4. (#148)
Browse files Browse the repository at this point in the history
* LCH-6061: Fix deprecations for symfony 3.4

* Update phpunit to v8

* return hint for setup

* More linting fixes

* Fix offset issue in data provider

* Drop Symfony 3.4 from composer.json and change order of arguments on event dispatch

* Change order of arguments in test

* Change pinning for symfony
  • Loading branch information
amangrover90 authored Jun 3, 2022
1 parent 1c9a67d commit 0a97044
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 33 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
"php": ">=7.3",
"psr/log": "~1.0",
"guzzlehttp/guzzle": "~6.0",
"symfony/event-dispatcher": "^3.4 || ^4.3",
"symfony/http-foundation": "^3.4 || ^4.3",
"symfony/serializer": "^3.4 || ^4.3"
"symfony/event-dispatcher": ">=4.4",
"symfony/http-foundation": ">=4.4",
"symfony/serializer": ">=4.4"
},
"require-dev": {
"drupal/coder": "dev-8.x-3.x",
"mockery/mockery": "^1.2",
"pdepend/pdepend": "~1.0",
"phploc/phploc": "~2.0",
"phpmd/phpmd": "~1.0",
"phpunit/phpunit": "^7",
"phpunit/phpunit": "^8",
"scrutinizer/ocular": "~1.0",
"sebastian/phpcpd": "~2.0",
"squizlabs/php_codesniffer": "^3.5"
Expand Down
2 changes: 1 addition & 1 deletion src/ContentHubClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public function getEntities(array $uuids) {
*/
protected function getCDFObject($data) { // phpcs:ignore
$event = ObjectFactory::getCDFTypeEvent($data);
$this->dispatcher->dispatch(ContentHubLibraryEvents::GET_CDF_CLASS, $event);
$this->dispatcher->dispatch($event, ContentHubLibraryEvents::GET_CDF_CLASS);

return $event->getObject();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Event/GetCDFTypeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Acquia\ContentHubClient\Event;

use Acquia\ContentHubClient\CDF\CDFObjectInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Class GetCDFTypeEvent.
Expand Down
28 changes: 14 additions & 14 deletions test/CDFDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ public function testToString(array $objectsList, $emptyObjectsJson, $filledObjec
public function providerEntityOperations() {
$cdfObjectMockFirst = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();
$cdfObjectMockSecond = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();

$cdfObjectMockFirst->expects($this->any())
Expand Down Expand Up @@ -272,11 +272,11 @@ public function providerEntityOperations() {
public function providerMergeDocuments() {
$cdfObjectMockFirst = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();
$cdfObjectMockSecond = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();

$cdfObjectMockFirst->expects($this->any())
Expand Down Expand Up @@ -307,11 +307,11 @@ public function providerMergeDocumentsNoOverlap() {
// First set of objects.
$setOneFirst = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();
$setOneSecond = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();

$setOneFirst->expects($this->any())
Expand All @@ -325,11 +325,11 @@ public function providerMergeDocumentsNoOverlap() {
// Second set of objects.
$setTwoFirst = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();
$setTwoSecond = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();

$setTwoFirst->expects($this->any())
Expand Down Expand Up @@ -376,11 +376,11 @@ public function providerMergeDocumentsOverlap() {
// First set of objects.
$setOneFirst = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();
$setOneSecond = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();

$setOneFirst->expects($this->any())
Expand All @@ -394,11 +394,11 @@ public function providerMergeDocumentsOverlap() {
// Second set of objects.
$setTwoFirst = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();
$setTwoSecond = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid'])
->onlyMethods(['getUuid'])
->getMock();

$setTwoFirst->expects($this->any())
Expand Down Expand Up @@ -444,11 +444,11 @@ public function providerMergeDocumentsOverlap() {
public function providerToString() {
$cdfObjectMockFirst = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid', 'toArray'])
->onlyMethods(['getUuid', 'toArray'])
->getMock();
$cdfObjectMockSecond = $this->getMockBuilder(CDFObject::class)
->disableOriginalConstructor()
->setMethods(['getUuid', 'toArray'])
->onlyMethods(['getUuid', 'toArray'])
->getMock();

$cdfObjectMockFirst->expects($this->any())
Expand Down
15 changes: 8 additions & 7 deletions test/ContentHubClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
Expand Down Expand Up @@ -610,7 +611,7 @@ public function testGetCDFObjectAlsoDispatchesGetCDFClassEvent(): void { // phpc
$this->dispatcher
->shouldReceive('dispatch')
->once()
->withArgs(static function (string $event_name, Event $event) {
->withArgs(static function (Event $event, string $event_name) {
return $event_name === ContentHubLibraryEvents::GET_CDF_CLASS;
});

Expand Down Expand Up @@ -2056,7 +2057,7 @@ private function makeMockResponse(
$response->shouldReceive('getStatusCode')->andReturn($status);
$response->shouldReceive('getHeaders')->andReturn($headers);
$response->shouldReceive('getBody')
->andReturn(\GuzzleHttp\Psr7\stream_for($body));
->andReturn(Utils::streamFor($body));

return $response;
}
Expand Down Expand Up @@ -2546,10 +2547,10 @@ public function testIsFeatured(array $remote_settings, bool $expectation): void
public function isFeaturedDataProvider(): array {
// A truncated response of /settings endpoint.
$response = [
'hostname' => $this->test_data['host-name'],
'api_key' => $this->test_data['api-key'],
'secret_key' => $this->test_data['secret-key'],
'shared_secret' => $this->test_data['shared-secret'],
'hostname' => 'some-host-name',
'api_key' => 'some-api-key',
'secret_key' => 'some-secret-key',
'shared_secret' => 'some-shared-secret',
'client_name' => 'client_name',
];

Expand Down
2 changes: 1 addition & 1 deletion test/EventSubscriber/ClientCDFTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private function getGetCDFTypeEvent(): GetCDFTypeEvent { // phpcs:ignore

return $this->getMockBuilder(GetCDFTypeEvent::class)
->disableOriginalConstructor()
->setMethods([
->onlyMethods([
'getType',
'setObject',
'stopPropagation',
Expand Down
2 changes: 1 addition & 1 deletion test/EventSubscriber/DefaultCDFTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testHandler() {

$getCDFTypeEventMock = $this->getMockBuilder(GetCDFTypeEvent::class)
->disableOriginalConstructor()
->setMethods(['setObject', 'stopPropagation', 'getData'])
->onlyMethods(['setObject', 'stopPropagation', 'getData'])
->getMock();

$getCDFTypeEventMock->expects($this->once())
Expand Down
4 changes: 2 additions & 2 deletions test/SearchCriteria/SearchCriteriaBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SearchCriteriaBuilderTest extends TestCase {
/**
* {@inheritDoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->default_search_criteria_data = [
Expand Down Expand Up @@ -71,7 +71,7 @@ protected function setUp() {
/**
* {@inheritDoc}
*/
protected function tearDown() {
protected function tearDown(): void {
parent::tearDown();
}

Expand Down
4 changes: 2 additions & 2 deletions test/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WebhookTest extends TestCase {
/**
* {@inheritDoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->definition = [
Expand All @@ -57,7 +57,7 @@ protected function setUp() {
/**
* {@inheritDoc}
*/
protected function tearDown() {
protected function tearDown(): void {
parent::tearDown();

unset($this->webhook, $this->definition);
Expand Down

0 comments on commit 0a97044

Please sign in to comment.