Skip to content

Commit

Permalink
Updated PHPUnit to 5.7 (#24)
Browse files Browse the repository at this point in the history
* Use PHPUnit v57

* Tests updated to use namespaced TestCase, also use class constants where is possible
  • Loading branch information
MarioBlazek authored and andrerom committed Oct 2, 2017
1 parent f9961ff commit b426a31
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 141 deletions.
69 changes: 36 additions & 33 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
{
"name": "ezsystems/ezplatform-xmltext-fieldtype",
"description": "XmlText field type implementation for eZ Platform",
"license": "GPL-2.0",
"type": "ezplatform-bundle",
"authors": [
{
"name": "eZ dev-team & eZ Community",
"homepage": "https://github.com/ezsystems/ezplatform-xmltext-fieldtype/contributors"
"name": "ezsystems/ezplatform-xmltext-fieldtype",
"description": "XmlText field type implementation for eZ Platform",
"license": "GPL-2.0",
"type": "ezplatform-bundle",
"authors": [
{
"name": "eZ dev-team & eZ Community",
"homepage": "https://github.com/ezsystems/ezplatform-xmltext-fieldtype/contributors"
}
],
"require": {
"ezsystems/ezpublish-kernel": "^6.11@dev"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"matthiasnoback/symfony-dependency-injection-test": "~1.0",
"ezsystems/ezplatform-solr-search-engine": "^1.0@dev,<1.3"
},
"autoload": {
"psr-4": {
"EzSystems\\EzPlatformXmlTextFieldTypeBundle\\": "bundle",
"eZ\\Publish\\Core\\FieldType\\XmlText\\": "lib/FieldType/XmlText",
"eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\FieldValue\\Converter\\": "lib/Persistence/Legacy/Content/FieldValue/Converter",
"eZ\\Publish\\Core\\REST\\Common\\FieldTypeProcessor\\": "lib/REST/Common/FieldTypeProcessor"
}
},
"autoload-dev": {
"psr-4": {
"EzSystems\\EzPlatformXmlTextFieldTypeBundle\\Tests\\": "tests/bundle",
"EzSystems\\EzPlatformXmlTextFieldType\\Tests\\": "tests/lib"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
}
],
"require": {
"ezsystems/ezpublish-kernel": "^6.11@dev"
},
"require-dev": {
"phpunit/phpunit": "~4.7",
"matthiasnoback/symfony-dependency-injection-test": "0.*",
"zendframework/zend-code": "~2.4.3",
"ezsystems/ezplatform-solr-search-engine": "^1.0@dev,<1.3"
},
"autoload": {
"psr-4": {
"EzSystems\\EzPlatformXmlTextFieldTypeBundle\\": "bundle",
"EzSystems\\EzPlatformXmlTextFieldTypeBundle\\Tests\\": "tests/bundle",
"eZ\\Publish\\Core\\FieldType\\XmlText\\": "lib/FieldType/XmlText",
"eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\FieldValue\\Converter\\": "lib/Persistence/Legacy/Content/FieldValue/Converter",
"eZ\\Publish\\Core\\REST\\Common\\FieldTypeProcessor\\": "lib/REST/Common/FieldTypeProcessor",
"EzSystems\\EzPlatformXmlTextFieldType\\Tests\\": "tests/lib"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testProcess()
$this->assertSame(1, count($calls));
list($method, $arguments) = $calls[0];
$this->assertSame('addPreConverter', $method);
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $arguments[0]);
$this->assertInstanceOf(Reference::class, $arguments[0]);
$this->assertSame('foo.converter', (string)$arguments[0]);
}

Expand Down Expand Up @@ -71,12 +71,9 @@ public function testAddPreConverter()
public function testSortConverterIds()
{
$container = new ContainerBuilder();
$html5ConvertDef = $this->getMock(
'Symfony\\Component\\DependencyInjection\\Definition',
array(
'addMethodCall',
)
);
$html5ConvertDef = $this->getMockBuilder(Definition::class)
->setMethods(['addMethodCall'])
->getMock();
$container->setDefinition('ezpublish.fieldType.ezxmltext.converter.html5', $html5ConvertDef);

$preConverterDef1 = new Definition();
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/FieldType/Converter/EmbedLinkingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
namespace EzSystems\EzPlatformXmlTextFieldType\Tests\FieldType\Converter;

use eZ\Publish\Core\FieldType\XmlText\Converter\EmbedLinking;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use DOMDocument;

/**
* Tests the EmbedLinking converter.
*/
class EmbedLinkingTest extends PHPUnit_Framework_TestCase
class EmbedLinkingTest extends TestCase
{
/**
* Provider for conversion test.
Expand Down
62 changes: 30 additions & 32 deletions tests/lib/FieldType/Converter/EmbedToHtml5Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@
namespace EzSystems\EzPlatformXmlTextFieldType\Tests\FieldType\Converter;

use eZ\Publish\Core\FieldType\XmlText\Converter\EmbedToHtml5;
use eZ\Publish\Core\Repository\LocationService;
use eZ\Publish\Core\Repository\Repository;
use eZ\Publish\API\Repository\Values\Content\VersionInfo as APIVersionInfo;
use eZ\Publish\Core\Repository\Values\Content\Location;
use eZ\Publish\Core\Repository\ContentService;
use eZ\Publish\API\Repository\Values\Content\Location as APILocation;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use PHPUnit_Framework_TestCase;
use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use PHPUnit\Framework\TestCase;
use DOMDocument;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
use Psr\Log\LoggerInterface;

/**
* Tests the EmbedToHtml5 Preconverter
* Class EmbedToHtml5Test.
*/
class EmbedToHtml5Test extends PHPUnit_Framework_TestCase
class EmbedToHtml5Test extends TestCase
{
/**
* @return array
Expand Down Expand Up @@ -589,37 +597,31 @@ class="itemized_sub_items"
*/
protected function getMockFragmentHandler()
{
return $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentHandler')
->disableOriginalConstructor()
->getMock();
return $this->createMock(FragmentHandler::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getMockContentService()
{
return $this->getMockBuilder('eZ\\Publish\\Core\\Repository\\ContentService')
->disableOriginalConstructor()
->getMock();
return $this->createMock(ContentService::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getMockLocationService()
{
return $this->getMockBuilder('eZ\\Publish\\Core\\Repository\\LocationService')
->disableOriginalConstructor()
->getMock();
return $this->createMock(LocationService::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getLoggerMock()
{
return $this->getMock('Psr\\Log\\LoggerInterface');
return $this->createMock(LoggerInterface::class);
}

/**
Expand All @@ -630,11 +632,7 @@ protected function getLoggerMock()
*/
protected function getMockRepository($contentService, $locationService)
{
$repositoryClass = 'eZ\\Publish\\Core\\Repository\\Repository';
$repository = $this
->getMockBuilder($repositoryClass)
->disableOriginalConstructor()
->getMock();
$repository = $this->createMock(Repository::class);

$repository->expects($this->any())
->method('sudo')
Expand Down Expand Up @@ -672,13 +670,13 @@ public function runNodeEmbedContent($xmlString, $contentId, $status, $view, $par
$fragmentHandler = $this->getMockFragmentHandler();
$contentService = $this->getMockContentService();

$versionInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo');
$versionInfo = $this->createMock(APIVersionInfo::class);
$versionInfo->expects($this->any())
->method('__get')
->with('status')
->will($this->returnValue($status));

$content = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Content');
$content = $this->createMock(Content::class);
$content->expects($this->any())
->method('getVersionInfo')
->will($this->returnValue($versionInfo));
Expand Down Expand Up @@ -721,7 +719,7 @@ public function runNodeEmbedContent($xmlString, $contentId, $status, $view, $par
$fragmentHandler,
$repository,
array('view', 'class', 'node_id', 'object_id'),
$this->getMock('Psr\\Log\\LoggerInterface')
$this->getLoggerMock()
);

$converter->convert($dom);
Expand Down Expand Up @@ -784,7 +782,7 @@ public function runNodeEmbedLocation($xmlString, $locationId, $view, $parameters
$fragmentHandler,
$repository,
array('view', 'class', 'node_id', 'object_id'),
$this->getMock('Psr\\Log\\LoggerInterface')
$this->getLoggerMock()
);

$converter->convert($dom);
Expand Down Expand Up @@ -857,13 +855,13 @@ public function testEmbedContentThrowsUnauthorizedException($permissionsMap)
$fragmentHandler = $this->getMockFragmentHandler();
$contentService = $this->getMockContentService();

$versionInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo');
$versionInfo = $this->createMock(APIVersionInfo::class);
$versionInfo->expects($this->any())
->method('__get')
->with('status')
->will($this->returnValue(APIVersionInfo::STATUS_DRAFT));

$content = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Content');
$content = $this->createMock(Content::class);
$content->expects($this->any())
->method('getVersionInfo')
->will($this->returnValue($versionInfo));
Expand Down Expand Up @@ -892,7 +890,7 @@ public function testEmbedContentThrowsUnauthorizedException($permissionsMap)
$fragmentHandler,
$repository,
array('view', 'class', 'node_id', 'object_id'),
$this->getMock('Psr\\Log\\LoggerInterface')
$this->getLoggerMock()
);

$converter->convert($dom);
Expand All @@ -909,8 +907,8 @@ public function testEmbedLocationThrowsUnauthorizedException()
$fragmentHandler = $this->getMockFragmentHandler();
$locationService = $this->getMockLocationService();

$contentInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo');
$location = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Location');
$contentInfo = $this->createMock(ContentInfo::class);
$location = $this->createMock(APILocation::class);
$location
->expects($this->exactly(2))
->method('getContentInfo')
Expand Down Expand Up @@ -939,7 +937,7 @@ public function testEmbedLocationThrowsUnauthorizedException()
$fragmentHandler,
$repository,
array('view', 'class', 'node_id', 'object_id'),
$this->getMock('Psr\\Log\\LoggerInterface')
$this->getLoggerMock()
);

$converter->convert($dom);
Expand Down Expand Up @@ -985,7 +983,7 @@ public function testEmbedContentNotFound($input, $output)
->with($this->equalTo(42))
->will(
$this->throwException(
$this->getMock('eZ\\Publish\\API\\Repository\\Exceptions\\NotFoundException')
$this->createMock(NotFoundException::class)
)
);

Expand Down Expand Up @@ -1053,7 +1051,7 @@ public function testEmbedLocationNotFound($input, $output)
->with($this->equalTo(42))
->will(
$this->throwException(
$this->getMock('eZ\\Publish\\API\\Repository\\Exceptions\\NotFoundException')
$this->createMock(NotFoundException::class)
)
);

Expand Down Expand Up @@ -1105,13 +1103,13 @@ public function testEmbedRemovesTextContent($input, $output, $contentReplacement
$fragmentHandler = $this->getMockFragmentHandler();
$contentService = $this->getMockContentService();

$versionInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo');
$versionInfo = $this->createMock(APIVersionInfo::class);
$versionInfo->expects($this->any())
->method('__get')
->with('status')
->will($this->returnValue($status));

$content = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Content');
$content = $this->createMock(Content::class);
$content->expects($this->any())
->method('getVersionInfo')
->will($this->returnValue($versionInfo));
Expand Down Expand Up @@ -1144,7 +1142,7 @@ public function testEmbedRemovesTextContent($input, $output, $contentReplacement
$fragmentHandler,
$repository,
array('view', 'class', 'node_id', 'object_id'),
$this->getMock('Psr\\Log\\LoggerInterface')
$this->getLoggerMock()
);

$converter->convert($dom);
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/FieldType/Converter/ExpandingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
namespace EzSystems\EzPlatformXmlTextFieldType\Tests\FieldType\Converter;

use eZ\Publish\Core\FieldType\XmlText\Converter\Expanding;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use DOMDocument;

/**
* Tests the Expanding converter.
*/
class ExpandingTest extends PHPUnit_Framework_TestCase
class ExpandingTest extends TestCase
{
/**
* Provider for conversion test.
Expand Down
Loading

0 comments on commit b426a31

Please sign in to comment.