Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Updated test to work with PHPUnit 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra committed Jan 15, 2019
1 parent a06b76b commit 182bcc0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
13 changes: 7 additions & 6 deletions test/src/Tests/Hydrator/DoctrineHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace PhproTest\DoctrineHydrationModule\Tests\Hydrator;

use Phpro\DoctrineHydrationModule\Hydrator\DoctrineHydrator;
use PHPUnit\Framework\TestCase;

/**
* Class DoctrineHydratorTest.
*/
class DoctrineHydratorTest extends \PHPUnit_Framework_TestCase
class DoctrineHydratorTest extends TestCase
{
/**
* @param null $hydrateService
Expand All @@ -17,8 +18,8 @@ class DoctrineHydratorTest extends \PHPUnit_Framework_TestCase
*/
protected function createHydrator($hydrateService = null, $extractService = null)
{
$hydrateService = $hydrateService ? $hydrateService : $this->getMock('Zend\Hydrator\HydratorInterface');
$extractService = $extractService ? $extractService : $this->getMock('Zend\Hydrator\HydratorInterface');
$hydrateService = $hydrateService ? $hydrateService : $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();
$extractService = $extractService ? $extractService : $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();

return new DoctrineHydrator($extractService, $hydrateService);
}
Expand Down Expand Up @@ -57,7 +58,7 @@ public function it_should_extract_an_object()
{
$object = new \stdClass();
$extracted = array('extracted' => true);
$extractService = $this->getMock('Zend\Hydrator\HydratorInterface');
$extractService = $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();
$extractService
->expects($this->any())
->method('extract')
Expand All @@ -77,7 +78,7 @@ public function it_should_hydrate_an_object()
$object = new \stdClass();
$data = array('field' => 'value');

$hydrateService = $this->getMock('Zend\Hydrator\HydratorInterface');
$hydrateService = $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();
$hydrateService
->expects($this->any())
->method('hydrate')
Expand All @@ -98,7 +99,7 @@ public function it_should_use_a_generated_doctrine_hydrator_while_hydrating_an_o
$object = new \stdClass();
$data = array('field' => 'value');

$hydrateService = $this->getMock('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface');
$hydrateService = $this->getMockBuilder('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface')->getMock();
$hydrateService
->expects($this->any())
->method('hydrate')
Expand Down
4 changes: 3 additions & 1 deletion test/src/Tests/Hydrator/ODM/MongoDB/DoctrineObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class DoctrineObjectTest extends BaseTest
*/
protected function createHydrator($objectManager = null)
{
$objectManager = $objectManager ? $objectManager : $this->getMock('Doctrine\ODM\MongoDB\DocumentManager', array(), array(), '', false);
$objectManager = $objectManager ? $objectManager : $this->getMockBuilder('Doctrine\ODM\MongoDB\DocumentManager')
->disableOriginalConstructor()
->getMock();
$hydrator = new DoctrineObject($objectManager);

return $hydrator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace PhproTest\DoctrineHydrationModule\Tests\Hydrator\ODM\MongoDB\Strategy;

use Phpro\DoctrineHydrationModule\Hydrator\ODM\MongoDB\Strategy\DateTimeField;
use PHPUnit\Framework\TestCase;

/**
* Class DateTimeFieldTest.
*/
class DateTimeFieldTest extends \PHPUnit_Framework_TestCase
class DateTimeFieldTest extends TestCase
{
/**
* @param bool $isTimestamp
Expand Down
3 changes: 2 additions & 1 deletion test/src/Tests/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace PhproTest\DoctrineHydrationModule\Tests;

use Phpro\DoctrineHydrationModule\Module;
use PHPUnit\Framework\TestCase;

/**
* Class ModuleTest.
*/
class ModuleTest extends \PHPUnit_Framework_TestCase
class ModuleTest extends TestCase
{
/**
* @test
Expand Down
33 changes: 25 additions & 8 deletions test/src/Tests/Service/DoctrineHydratorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use PhproTest\DoctrineHydrationModule\Hydrator\CustomBuildHydratorFactory;
use Phpro\DoctrineHydrationModule\Service\DoctrineHydratorFactory;
use PHPUnit\Framework\TestCase;
use Zend\ServiceManager\ServiceManager;
use Zend\Hydrator\HydratorPluginManager;

class DoctrineHydratorFactoryTest extends \PHPUnit_Framework_TestCase
class DoctrineHydratorFactoryTest extends TestCase
{
/**
* @var array
Expand All @@ -34,9 +35,18 @@ protected function setUp()
$this->serviceManager = new ServiceManager();
$this->serviceManager->setAllowOverride(true);
$this->serviceManager->setService('config', $this->serviceConfig);
$this->serviceManager->setService('custom.strategy', $this->getMock('Zend\Hydrator\Strategy\StrategyInterface'));
$this->serviceManager->setService('custom.filter', $this->getMock('Zend\Hydrator\Filter\FilterInterface'));
$this->serviceManager->setService('custom.naming_strategy', $this->getMock('Zend\Hydrator\NamingStrategy\NamingStrategyInterface'));
$this->serviceManager->setService(
'custom.strategy',
$this->getMockBuilder('Zend\Hydrator\Strategy\StrategyInterface')->getMock()
);
$this->serviceManager->setService(
'custom.filter',
$this->getMockBuilder('Zend\Hydrator\Filter\FilterInterface')->getMock()
);
$this->serviceManager->setService(
'custom.naming_strategy',
$this->getMockBuilder('Zend\Hydrator\NamingStrategy\NamingStrategyInterface')->getMock()
);

$this->hydratorManager = $this->getMockBuilder(HydratorPluginManager::class)
->disableOriginalConstructor()
Expand All @@ -55,7 +65,9 @@ protected function setUp()
*/
protected function stubObjectManager($objectManagerClass)
{
$objectManager = $this->getMock($objectManagerClass, array(), array(), '', false);
$objectManager = $this->getMockBuilder($objectManagerClass)
->disableOriginalConstructor()
->getMock();
$this->serviceManager->setService('doctrine.default.object-manager', $objectManager);

return $objectManager;
Expand Down Expand Up @@ -153,8 +165,10 @@ public function it_should_create_a_custom_ODM_hydrator_which_uses_the_auto_gener
$this->serviceManager->setService('config', $this->serviceConfig);
$objectManager = $this->stubObjectManager('Doctrine\ODM\MongoDb\DocumentManager');

$hydratorFactory = $this->getMock('Doctrine\ODM\MongoDB\Hydrator\HydratorFactory', array(), array(), '', false);
$generatedHydrator = $this->getMock('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface');
$hydratorFactory = $this->getMockBuilder('Doctrine\ODM\MongoDB\Hydrator\HydratorFactory')
->disableOriginalConstructor()
->getMock();
$generatedHydrator = $this->getMockBuilder('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface')->getMock();

$objectManager
->expects($this->any())
Expand Down Expand Up @@ -183,7 +197,10 @@ public function it_should_be_possible_to_configure_a_custom_hydrator()
$this->serviceConfig['doctrine-hydrator']['custom-hydrator']['hydrator'] = 'custom.hydrator';
$this->serviceManager->setService('config', $this->serviceConfig);

$this->serviceManager->setService('custom.hydrator', $this->getMock('Zend\Hydrator\ArraySerializable'));
$this->serviceManager->setService(
'custom.hydrator',
$this->getMockBuilder('Zend\Hydrator\ArraySerializable')->getMock()
);

$hydrator = $this->createOrmHydrator();

Expand Down

0 comments on commit 182bcc0

Please sign in to comment.