From 9a25f36bf00df132d621db3a38d037bc916ae2a6 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 7 Oct 2020 16:19:37 +0200 Subject: [PATCH] allow php 8 --- .travis.yml | 1 + CHANGELOG.md | 5 + composer.json | 6 +- phpunit.xml.dist | 1 - src/Jackalope/Transport/Jackrabbit/Client.php | 5 +- .../Query/QOM/QueryObjectModelFactoryTest.php | 4 +- tests/Jackalope/Test/JackrabbitTestCase.php | 2 +- .../Transport/Jackrabbit/ClientTest.php | 94 +++++++++---------- .../Transport/Jackrabbit/EventBufferTest.php | 45 ++++----- .../Transport/Jackrabbit/PrefetchTest.php | 10 +- .../Transport/Jackrabbit/RequestTest.php | 26 ++++- 11 files changed, 108 insertions(+), 91 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2cc10e05..9143affe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - 7.2 - 7.3 - 7.4 + - nightly sudo: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b68e272..7e1b7483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +1.4.1 +----- + +* Allow PHP 8.0 + 1.4 --- diff --git a/composer.json b/composer.json index 0686693e..c78945b2 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "ext-xml":"*", "ext-dom": "*", "ext-curl":"*", @@ -28,9 +28,9 @@ }, "require-dev": { "psr/log": "~1.0", - "phpcr/phpcr-api-tests": "2.1.21", + "phpcr/phpcr-api-tests": "2.1.22", "symfony/console": "^2.3 || ^3.4 || ^4.3 || ^5.0", - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": "^7.5 || ^8.0 || ^9.0" }, "autoload": { "psr-0": { "Jackalope\\": "src/" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c977c394..69241836 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,7 +6,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="true" bootstrap="tests/bootstrap.php"> diff --git a/src/Jackalope/Transport/Jackrabbit/Client.php b/src/Jackalope/Transport/Jackrabbit/Client.php index 9de2edf3..3ded836c 100644 --- a/src/Jackalope/Transport/Jackrabbit/Client.php +++ b/src/Jackalope/Transport/Jackrabbit/Client.php @@ -167,7 +167,7 @@ class Client extends BaseTransport implements JackrabbitClientInterface /** * A list of additional HTTP headers to be sent on each request - * @var array[]string + * @var string[] */ protected $defaultHeaders = array(); @@ -199,7 +199,7 @@ class Client extends BaseTransport implements JackrabbitClientInterface * * This is our exception to the rule that nothing may be cached in transport. * - * @var array of strings as returned by getRepositoryDescriptors + * @var string[] as returned by getRepositoryDescriptors */ protected $descriptors = null; @@ -293,6 +293,7 @@ protected function getRequest($method, $uri, $addWorkspacePathToUri = true) } } + /** @var Request $request */ $request = $this->factory->get('Transport\\Jackrabbit\\Request', array($this, $curl, $method, $uri)); $request->setCredentials($this->credentials); diff --git a/tests/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactoryTest.php b/tests/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactoryTest.php index b08e1fbe..d82b95f4 100644 --- a/tests/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactoryTest.php +++ b/tests/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactoryTest.php @@ -20,13 +20,13 @@ class QueryObjectModelFactoryTest extends TestCase */ protected $qb; - public function setUp() + public function setUp(): void { $this->qf = new QueryObjectModelFactory(new Factory()); $this->qb = new QueryBuilder($this->qf); } - public function testStatements() + public function testStatements(): void { //simple query, should be sql $this->qb->from($this->qf->selector('nt:base', "nt:base")); diff --git a/tests/Jackalope/Test/JackrabbitTestCase.php b/tests/Jackalope/Test/JackrabbitTestCase.php index a2e89826..3aec2125 100644 --- a/tests/Jackalope/Test/JackrabbitTestCase.php +++ b/tests/Jackalope/Test/JackrabbitTestCase.php @@ -6,7 +6,7 @@ abstract class JackrabbitTestCase extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Jackalope/Transport/Jackrabbit/ClientTest.php b/tests/Jackalope/Transport/Jackrabbit/ClientTest.php index 2801c800..dfa31a19 100644 --- a/tests/Jackalope/Transport/Jackrabbit/ClientTest.php +++ b/tests/Jackalope/Transport/Jackrabbit/ClientTest.php @@ -9,7 +9,6 @@ use Jackalope\Transport\Jackrabbit\Client; use Jackalope\Transport\Jackrabbit\Request; use PHPCR\LoginException; -use PHPCR\NodeType\NoSuchNodeTypeException; use PHPCR\NoSuchWorkspaceException; use PHPCR\RepositoryException; use PHPUnit\Framework\MockObject\MockObject; @@ -18,6 +17,7 @@ use PHPCR\ValueFormatException; use Jackalope\NodeType\NodeTypeManager; use Jackalope\ObjectManager; +use Jackalope\Transport\RemoveNodeOperation; /** * TODO: this unit test contains some functional tests. we should separate functional and unit tests. @@ -67,7 +67,7 @@ public function getRequestMock($response = '', $changeMethods = array()) /** * @covers \Jackalope\Transport\Jackrabbit\Client::__construct */ - public function testConstructor() + public function testConstructor(): void { $factory = new Factory; $transport = new ClientMock($factory, 'testuri'); @@ -77,7 +77,7 @@ public function testConstructor() /** * @covers \Jackalope\Transport\Jackrabbit\Client::__destruct */ - public function testDestructor() + public function testDestructor(): void { $factory = new Factory; $transport = new ClientMock($factory, 'testuri'); @@ -88,7 +88,7 @@ public function testDestructor() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getRequest */ - public function testGetRequestDoesntReinitCurl() + public function testGetRequestDoesntReinitCurl(): void { $t = $this->getTransportMock(); $t->curl = 'test'; @@ -99,7 +99,7 @@ public function testGetRequestDoesntReinitCurl() /** * @covers \Jackalope\Transport\Jackrabbit\Client::buildReportRequest */ - public function testBuildReportRequest() + public function testBuildReportRequest(): void { $this->assertSame( '', @@ -110,7 +110,7 @@ public function testBuildReportRequest() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getRepositoryDescriptors */ - public function testGetRepositoryDescriptorsEmptyBackendResponse() + public function testGetRepositoryDescriptorsEmptyBackendResponse(): void { $dom = new DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/empty.xml'); @@ -126,7 +126,7 @@ public function testGetRepositoryDescriptorsEmptyBackendResponse() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getRepositoryDescriptors */ - public function testGetRepositoryDescriptors() + public function testGetRepositoryDescriptors(): void { $reportRequest = $this->getTransportMock()->buildReportRequestMock('dcr:repositorydescriptors'); $dom = new DOMDocument(); @@ -136,7 +136,7 @@ public function testGetRepositoryDescriptors() $t->expects($this->once()) ->method('getRequest') ->with(Request::REPORT, 'testuri/') - ->will($this->returnValue($request)); + ->willReturn($request); $request->expects($this->once()) ->method('setBody') ->with($reportRequest); @@ -153,7 +153,7 @@ public function testGetRepositoryDescriptors() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getRequest */ - public function testExceptionIfNotLoggedIn() + public function testExceptionIfNotLoggedIn(): void { $factory = new Factory; $t = new ClientMock($factory, 'http://localhost:1/server'); @@ -164,7 +164,7 @@ public function testExceptionIfNotLoggedIn() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getRepositoryDescriptors */ - public function testGetRepositoryDescriptorsNoserver() + public function testGetRepositoryDescriptorsNoserver(): void { $factory = new Factory; $t = new Client($factory, 'http://localhost:1/server'); @@ -175,7 +175,7 @@ public function testGetRepositoryDescriptorsNoserver() /** * @covers \Jackalope\Transport\Jackrabbit\Client::buildPropfindRequest */ - public function testBuildPropfindRequestSingle() + public function testBuildPropfindRequestSingle(): void { $xmlStr = ''; $xmlStr .= ''; @@ -186,7 +186,7 @@ public function testBuildPropfindRequestSingle() /** * @covers \Jackalope\Transport\Jackrabbit\Client::buildPropfindRequest */ - public function testBuildPropfindRequestArray() + public function testBuildPropfindRequestArray(): void { $xmlStr = ''; $xmlStr .= ''; @@ -197,7 +197,7 @@ public function testBuildPropfindRequestArray() /** * @covers \Jackalope\Transport\Jackrabbit\Client::login */ - public function testLoginAlreadyLoggedin() + public function testLoginAlreadyLoggedin(): void { $t = $this->getTransportMock(); $t->setCredentials('test'); @@ -208,7 +208,7 @@ public function testLoginAlreadyLoggedin() /** * @covers \Jackalope\Transport\Jackrabbit\Client::login */ - public function testLoginUnsportedCredentials() + public function testLoginUnsportedCredentials(): void { $t = $this->getTransportMock(); $this->expectException(LoginException::class); @@ -218,7 +218,7 @@ public function testLoginUnsportedCredentials() /** * @covers \Jackalope\Transport\Jackrabbit\Client::login */ - public function testLoginEmptyBackendResponse() + public function testLoginEmptyBackendResponse(): void { $dom = new DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/empty.xml'); @@ -234,7 +234,7 @@ public function testLoginEmptyBackendResponse() /** * @covers \Jackalope\Transport\Jackrabbit\Client::login */ - public function testLoginWrongWorkspace() + public function testLoginWrongWorkspace(): void { $dom = new DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/wrongWorkspace.xml'); @@ -250,7 +250,7 @@ public function testLoginWrongWorkspace() /** * @covers \Jackalope\Transport\Jackrabbit\Client::login */ - public function testLogin() + public function testLogin(): void { $propfindRequest = $this->getTransportMock()->buildPropfindRequestMock(array('D:workspace', 'dcr:workspaceName')); $dom = new DOMDocument(); @@ -261,7 +261,7 @@ public function testLogin() $t->expects($this->once()) ->method('getRequest') ->with(Request::PROPFIND, 'testuri/tests') - ->will($this->returnValue($request)); + ->willReturn($request); $request->expects($this->once()) ->method('setBody') @@ -276,7 +276,7 @@ public function testLogin() /** * @covers \Jackalope\Transport\Jackrabbit\Client::login */ - public function testLoginNoServer() + public function testLoginNoServer(): void { $factory = new Factory; $t = new Client($factory, 'http://localhost:1/server'); @@ -287,7 +287,7 @@ public function testLoginNoServer() /** * @covers \Jackalope\Transport\Jackrabbit\Client::login */ - public function testLoginNoSuchWorkspace() + public function testLoginNoSuchWorkspace(): void { $factory = new Factory; $t = new Client($factory, $this->config['url']); @@ -298,7 +298,7 @@ public function testLoginNoSuchWorkspace() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getNode */ - public function testGetNodeWithoutAbsPath() + public function testGetNodeWithoutAbsPath(): void { $t = $this->getTransportMock(); $this->expectException(RepositoryException::class); @@ -308,7 +308,7 @@ public function testGetNodeWithoutAbsPath() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getNode */ - public function testGetNode() + public function testGetNode(): void { $t = $this->getTransportMock($this->config['url']); @@ -324,7 +324,7 @@ public function testGetNode() /** * @covers \Jackalope\Transport\Jackrabbit\Client::buildLocateRequest */ - public function testBuildLocateRequestMock() + public function testBuildLocateRequestMock(): void { $xmlstr = 'test'; $this->assertSame($xmlstr, $this->getTransportMock()->buildLocateRequestMock('test')); @@ -333,7 +333,7 @@ public function testBuildLocateRequestMock() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getNamespaces */ - public function testGetNamespacesEmptyResponse() + public function testGetNamespacesEmptyResponse(): void { $dom = new DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/empty.xml'); @@ -351,7 +351,7 @@ public function testGetNamespacesEmptyResponse() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getNamespaces */ - public function testGetNamespaces() + public function testGetNamespaces(): void { $reportRequest = $this->getTransportMock()->buildReportRequestMock('dcr:registerednamespaces'); $dom = new DOMDocument(); @@ -399,7 +399,7 @@ protected function setUpNodeTypeMock($params, $fixture) /** * @covers \Jackalope\Transport\Jackrabbit\Client::buildNodeTypesRequest */ - public function testGetAllNodeTypesRequest() + public function testGetAllNodeTypesRequest(): void { $xmlStr = ''; $this->assertSame($xmlStr, $this->getTransportMock()->buildNodeTypesRequestMock(array())); @@ -408,7 +408,7 @@ public function testGetAllNodeTypesRequest() /** * @covers \Jackalope\Transport\Jackrabbit\Client::buildNodeTypesRequest */ - public function testSpecificNodeTypesRequest() + public function testSpecificNodeTypesRequest(): void { $xmlStr= 'foobarfoobar'; $this->assertSame($xmlStr, $this->getTransportMock()->buildNodeTypesRequestMock(array('foo', 'bar', 'foobar'))); @@ -417,7 +417,7 @@ public function testSpecificNodeTypesRequest() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getNodeTypes */ - public function testGetNodeTypes() + public function testGetNodeTypes(): void { $t = $this->setUpNodeTypeMock(array(), __DIR__.'/../../../fixtures/nodetypes.xml'); @@ -429,7 +429,7 @@ public function testGetNodeTypes() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getNodeTypes */ - public function testSpecificGetNodeTypes() + public function testSpecificGetNodeTypes(): void { $t = $this->setUpNodeTypeMock(array('nt:folder', 'nt:file'), __DIR__.'/../../../fixtures/small_nodetypes.xml'); @@ -443,7 +443,7 @@ public function testSpecificGetNodeTypes() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getNodeTypes */ - public function testEmptyGetNodeTypes() + public function testEmptyGetNodeTypes(): void { $t = $this->setUpNodeTypeMock(array(), __DIR__.'/../../../fixtures/empty.xml'); @@ -456,7 +456,7 @@ public function testEmptyGetNodeTypes() /** * @covers \Jackalope\Transport\Jackrabbit\Client::getAccessibleWorkspaceNames */ - public function testGetAccessibleWorkspaceNames() + public function testGetAccessibleWorkspaceNames(): void { $dom = new DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/accessibleWorkspaces.xml'); @@ -466,7 +466,7 @@ public function testGetAccessibleWorkspaceNames() $t->expects($this->once()) ->method('getRequest') ->with(Request::PROPFIND, 'testuri/') - ->will($this->returnValue($request)); + ->willReturn($request); $request->expects($this->once()) ->method('setBody') ->with($this->getTransportMock()->buildPropfindRequestMock(array('D:workspace'))); @@ -481,7 +481,7 @@ public function testGetAccessibleWorkspaceNames() /** * @covers \Jackalope\Transport\Jackrabbit\Client::addWorkspacePathToUri */ - public function testAddWorkspacePathToUri() + public function testAddWorkspacePathToUri(): void { $factory = new Factory; $transport = new ClientMock($factory, ''); @@ -495,14 +495,12 @@ public function testAddWorkspacePathToUri() /** * @dataProvider deleteNodesProvider */ - public function testDeleteNodes($nodePaths, $expectedJsopString) + public function testDeleteNodes($nodePaths, $expectedJsopString): void { $t = $this->getTransportMock(); foreach ($nodePaths as $nodePath) { - $node = $this->getMockBuilder('Jackalope\Transport\RemoveNodeOperation') - ->disableOriginalConstructor() - ->getMock(); + $node = $this->createMock(RemoveNodeOperation::class); $node->srcPath = $nodePath; $nodes[] = $node; } @@ -515,7 +513,7 @@ public function testDeleteNodes($nodePaths, $expectedJsopString) $this->assertEquals($expectedJsopString, $jsopBody[':diff']); } - public function deleteNodesProvider() + public function deleteNodesProvider(): array { return array( array( @@ -557,7 +555,7 @@ public function deleteNodesProvider() /** * @dataProvider provideTestOutOfRangeCharacters */ - public function testOutOfRangeCharacterOccurrence($string, $isValid) + public function testOutOfRangeCharacterOccurrence($string, $isValid): void { if (false === $isValid) { $this->expectException(ValueFormatException::class); @@ -569,7 +567,7 @@ public function testOutOfRangeCharacterOccurrence($string, $isValid) $factory = new Factory; $session = $this->createMock(Session::class); $workspace = $this->createMock(Workspace::class); - $session->expects($this->any()) + $session ->method('getWorkspace') ->with() ->willReturn($workspace); @@ -594,7 +592,7 @@ public function testOutOfRangeCharacterOccurrence($string, $isValid) $t->updateProperties($article); } - public function provideTestOutOfRangeCharacters() + public function provideTestOutOfRangeCharacters(): array { // use http://rishida.net/tools/conversion/ to convert problematic utf-16 strings to code points return array( @@ -643,27 +641,27 @@ public function __construct($factory, $serverUri) } $this->server = $serverUri; } - public function buildNodeTypesRequestMock(array $params) + public function buildNodeTypesRequestMock(array $params): string { return $this->buildNodeTypesRequest($params); } - public function buildReportRequestMock($name = '') + public function buildReportRequestMock($name = ''): string { return $this->buildReportRequest($name); } - public function buildPropfindRequestMock($args = array()) + public function buildPropfindRequestMock($args = array()): string { return $this->buildPropfindRequest($args); } - public function buildLocateRequestMock($arg = '') + public function buildLocateRequestMock($arg = ''): string { return $this->buildLocateRequest($arg); } - public function setCredentials($credentials) + public function setCredentials($credentials): void { $this->credentials = $credentials; } @@ -673,12 +671,12 @@ public function getRequestMock($method, $uri) return $this->getRequest($method, $uri); } - public function addWorkspacePathToUriMock($uri) + public function addWorkspacePathToUriMock($uri): string { return $this->addWorkspacePathToUri($uri); } - public function getJsopBody() + public function getJsopBody(): array { return $this->jsopBody; } diff --git a/tests/Jackalope/Transport/Jackrabbit/EventBufferTest.php b/tests/Jackalope/Transport/Jackrabbit/EventBufferTest.php index 81ffd071..aff691b1 100644 --- a/tests/Jackalope/Transport/Jackrabbit/EventBufferTest.php +++ b/tests/Jackalope/Transport/Jackrabbit/EventBufferTest.php @@ -45,7 +45,7 @@ class EventBufferTest extends TestCase /** @var Event */ protected $expectedEventWithInfo; - public function setUp() + public function setUp(): void { $this->factory = new Factory(); $this->transport = $this->createMock(Client::class); @@ -134,7 +134,7 @@ public function setUp() $this->expectedEventWithInfo->addInfo('srcAbsPath', '/my_node'); } - public function testExtractUserId() + public function testExtractUserId(): void { $xml = 'admin'; $res = $this->getAndCallMethod($this->buffer, 'extractUserId', array($this->getDomElement($xml))); @@ -145,7 +145,7 @@ public function testExtractUserId() $this->assertEquals('', $res); } - public function testExtractUserIdNoAuthor() + public function testExtractUserIdNoAuthor(): void { $xml = 'admin'; @@ -153,14 +153,14 @@ public function testExtractUserIdNoAuthor() $this->getAndCallMethod($this->buffer, 'extractUserId', array($this->getDomElement($xml))); } - public function testExtractUserIdNoName() + public function testExtractUserIdNoName(): void { $xml = 'admin'; $this->expectException(RepositoryException::class); $this->getAndCallMethod($this->buffer, 'extractUserId', array($this->getDomElement($xml))); } - public function testFiltering() + public function testFiltering(): void { $this->filter->setAbsPath('/something-not-matching'); @@ -171,7 +171,7 @@ public function testFiltering() $this->assertEquals(array(), $events); } - public function testExtractEventType() + public function testExtractEventType(): void { $validEventTypes = array( 'nodeadded' => EventInterface::NODE_ADDED, @@ -190,28 +190,28 @@ public function testExtractEventType() } } - public function testExtractEventTypeInvalidType() + public function testExtractEventTypeInvalidType(): void { $xml = ''; $this->expectException(RepositoryException::class); $this->getAndCallMethod($this->buffer, 'extractEventType', array($this->getDomElement($xml))); } - public function testExtractEventTypeNoType() + public function testExtractEventTypeNoType(): void { $xml = ''; $this->expectException(RepositoryException::class); $this->getAndCallMethod($this->buffer, 'extractEventType', array($this->getDomElement($xml))); } - public function testExtractEventTypeMalformed() + public function testExtractEventTypeMalformed(): void { $xml = 'some string'; $this->expectException(RepositoryException::class); $this->getAndCallMethod($this->buffer, 'extractEventType', array($this->getDomElement($xml))); } - public function testEventInfo() + public function testEventInfo(): void { $events = $this->getAndCallMethod($this->buffer, 'extractEvents', array($this->getDomElement($this->eventWithInfoXml), 'system')); $this->assertCount(1, $events); @@ -235,39 +235,30 @@ public function testEventInfo() } $this->nodeTypeManager - ->expects($this->at(0)) ->method('getNodeType') - ->with('{internal}root') - ->willReturn(true) - ; - $this->nodeTypeManager - ->expects($this->at(1)) - ->method('getNodeType') - ->with('{internal}AccessControllable') - ->willReturn(true) + ->withConsecutive(['{internal}root'], ['{internal}AccessControllable']) + ->willReturnOnConsecutiveCalls(true, true) ; $this->assertTrue($eventWithInfo->getPrimaryNodeType()); $this->assertEquals(array('{internal}AccessControllable' => true), $eventWithInfo->getMixinNodeTypes()); } - public function testEmptyEventInfo() + public function testEmptyEventInfo(): void { - // get an event that has no eventinfo + /** @var Event[] $events */ $events = $this->getAndCallMethod($this->buffer, 'extractEvents', array($this->getDomElement($this->eventXml), 'system')); $this->assertCount(1, $events); $event = $events[0]; - $this->assertInstanceOf('Jackalope\Observation\Event', $event); - /** @var $event Event */ $eventInfo = $event->getInfo(); - $this->assertInternalType('array', $eventInfo); - $this->assertEquals(0, count($eventInfo)); + $this->assertIsArray($eventInfo); + $this->assertCount(0, $eventInfo); } - public function testIterator() + public function testIterator(): void { $dom = new \DOMDocument(); $dom->loadXML($this->entryXml); @@ -299,7 +290,7 @@ public function testIterator() $this->assertEquals($this->expectedEvent, $buffer->current()); } - public function testFetchPage() + public function testFetchPage(): void { $dom = new \DOMDocument(); $dom->loadXML($this->entryXml); diff --git a/tests/Jackalope/Transport/Jackrabbit/PrefetchTest.php b/tests/Jackalope/Transport/Jackrabbit/PrefetchTest.php index 7039be87..e1ddd422 100644 --- a/tests/Jackalope/Transport/Jackrabbit/PrefetchTest.php +++ b/tests/Jackalope/Transport/Jackrabbit/PrefetchTest.php @@ -27,7 +27,7 @@ class PrefetchTest extends TestCase */ protected static $loader; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); self::$loader = \ImplementationLoader::getInstance(); @@ -51,7 +51,7 @@ public static function setUpBeforeClass() $session->save(); } - protected function getTransport() + protected function getTransport(): Client { $transport = new \Jackalope\Transport\Jackrabbit\Client(new \Jackalope\Factory(), $GLOBALS['jackrabbit.uri']); $transport->login(self::$loader->getCredentials(), self::$loader->getWorkspaceName()); @@ -59,7 +59,7 @@ protected function getTransport() return $transport; } - public function testGetNode() + public function testGetNode(): void { $transport = $this->getTransport(); $transport->setFetchDepth(1); @@ -69,7 +69,7 @@ public function testGetNode() $this->assertNode($raw, 'a'); } - public function testGetNodes() + public function testGetNodes(): void { $transport = $this->getTransport(); $transport->setFetchDepth(1); @@ -87,7 +87,7 @@ public function testGetNodes() $this->assertNode($raw, 'b'); } - protected function assertNode($raw, $parent) + protected function assertNode($raw, $parent): void { $this->assertInstanceOf('\stdClass', $raw); $name = "child-a"; diff --git a/tests/Jackalope/Transport/Jackrabbit/RequestTest.php b/tests/Jackalope/Transport/Jackrabbit/RequestTest.php index 1d56ba9e..e2bc7629 100644 --- a/tests/Jackalope/Transport/Jackrabbit/RequestTest.php +++ b/tests/Jackalope/Transport/Jackrabbit/RequestTest.php @@ -8,6 +8,7 @@ use Jackalope\Transport\Jackrabbit\Client; use Jackalope\Transport\Jackrabbit\Request; use PHPCR\SimpleCredentials; +use PHPUnit\Framework\MockObject\MockObject; class RequestTest extends JackrabbitTestCase { @@ -75,15 +76,36 @@ public function testPrepareRequestWithCredentials() { $request = $this->getRequest('fixtures/empty.xml'); $request->setCredentials(new SimpleCredentials('foo', 'bar')); - $request->getCurl()->expects($this->at(0)) + $passwordParam = false; + $passwordCorrect = false; + $request->getCurl() ->method('setopt') - ->with(CURLOPT_USERPWD, 'foo:bar'); + ->with( + $this->callback(static function ($name) use (&$passwordParam): bool { + if (CURLOPT_USERPWD === $name) { + $passwordParam = true; + } + return true; + }), + $this->callback(static function ($value) use (&$passwordCorrect): bool { + if ('foo:bar' === $value) { + $passwordCorrect = true; + } + return true; + }) + ) + ; $request->execute(); + $this->assertTrue($passwordParam); + $this->assertTrue($passwordCorrect); } } class RequestMock extends Request { + /** + * @return curl|MockObject + */ public function getCurl() { return $this->curl;