Skip to content

Commit

Permalink
Remove MockBuilderCompatibilityTools (#9814)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Jun 3, 2022
1 parent b8299fe commit 7e20e97
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 66 deletions.
11 changes: 4 additions & 7 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools;
use PHPUnit\Framework\TestCase;

/**
* @group DDC-2359
*/
class DDC2359Test extends TestCase
{
use MockBuilderCompatibilityTools;

/**
* Verifies that {@see \Doctrine\ORM\Mapping\ClassMetadataFactory::wakeupReflection} is
* not called twice when loading metadata from a driver
Expand All @@ -35,12 +32,12 @@ public function testIssue(): void
$mockMetadata = $this->createMock(ClassMetadata::class);
$entityManager = $this->createMock(EntityManager::class);

$metadataFactory = $this
->getMockBuilderWithOnlyMethods(ClassMetadataFactory::class, ['newClassMetadataInstance', 'wakeupReflection'])
$metadataFactory = $this->getMockBuilder(ClassMetadataFactory::class)
->onlyMethods(['newClassMetadataInstance', 'wakeupReflection'])
->getMock();

$configuration = $this
->getMockBuilderWithOnlyMethods(Configuration::class, ['getMetadataDriverImpl'])
$configuration = $this->getMockBuilder(Configuration::class)
->onlyMethods(['getMetadataDriverImpl'])
->getMock();

$connection = $this->createMock(Connection::class);
Expand Down
9 changes: 4 additions & 5 deletions tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@
use Doctrine\Tests\Models\Forum\ForumCategory;
use Doctrine\Tests\Models\Hydration\EntityWithArrayDefaultArrayValueM2M;
use Doctrine\Tests\Models\Hydration\SimpleEntity;
use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools;

use function count;

class ObjectHydratorTest extends HydrationTestCase
{
use MockBuilderCompatibilityTools;

/**
* @psalm-return list<array{mixed}>
*/
Expand Down Expand Up @@ -1038,7 +1035,8 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void
$proxyInstance = new ECommerceShipping();

// mocking the proxy factory
$proxyFactory = $this->getMockBuilderWithOnlyMethods(ProxyFactory::class, ['getProxy'])
$proxyFactory = $this->getMockBuilder(ProxyFactory::class)
->onlyMethods(['getProxy'])
->disableOriginalConstructor()
->getMock();

Expand Down Expand Up @@ -1086,7 +1084,8 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE
$proxyInstance = new ECommerceShipping();

// mocking the proxy factory
$proxyFactory = $this->getMockBuilderWithOnlyMethods(ProxyFactory::class, ['getProxy'])
$proxyFactory = $this->getMockBuilder(ProxyFactory::class)
->onlyMethods(['getProxy'])
->disableOriginalConstructor()
->getMock();

Expand Down
6 changes: 2 additions & 4 deletions tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\ORM\Id\SequenceGenerator;
use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools;

class SequenceGeneratorTest extends OrmTestCase
{
use MockBuilderCompatibilityTools;

public function testGeneration(): void
{
$sequenceGenerator = new SequenceGenerator('seq', 10);
Expand All @@ -23,7 +20,8 @@ public function testGeneration(): void
$platform->method('getSequenceNextValSQL')
->willReturn('');

$connection = $this->getMockBuilderWithOnlyMethods(Connection::class, ['fetchOne', 'getDatabasePlatform'])
$connection = $this->getMockBuilder(Connection::class)
->onlyMethods(['fetchOne', 'getDatabasePlatform'])
->setConstructorArgs([[], $this->createMock(Driver::class)])
->getMock();
$connection->method('getDatabasePlatform')
Expand Down
2 changes: 0 additions & 2 deletions tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
use Doctrine\Tests\Models\Quote\Phone;
use Doctrine\Tests\Models\Quote\User;
use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools;
use DoctrineGlobalArticle;
use Exception;
use InvalidArgumentException;
Expand All @@ -55,7 +54,6 @@

class ClassMetadataFactoryTest extends OrmTestCase
{
use MockBuilderCompatibilityTools;
use VerifyDeprecations;

public function testGetMetadataForSingleClass(): void
Expand Down
18 changes: 8 additions & 10 deletions tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Doctrine\Tests\Models\Company\CompanyPerson;
use Doctrine\Tests\Models\ECommerce\ECommerceFeature;
use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools;
use ReflectionProperty;
use stdClass;

Expand All @@ -32,8 +31,6 @@
*/
class ProxyFactoryTest extends OrmTestCase
{
use MockBuilderCompatibilityTools;

private UnitOfWorkMock $uowMock;

private EntityManagerMock $emMock;
Expand All @@ -60,7 +57,8 @@ public function testReferenceProxyDelegatesLoadingToThePersister(): void
{
$identifier = ['id' => 42];
$proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature';
$persister = $this->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load'])
$persister = $this->getMockBuilder(BasicEntityPersister::class)
->onlyMethods(['load'])
->disableOriginalConstructor()
->getMock();

Expand Down Expand Up @@ -123,8 +121,8 @@ public function testSkipAbstractClassesOnGeneration(): void
*/
public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void
{
$persister = $this
->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load', 'getClassMetadata'])
$persister = $this->getMockBuilder(BasicEntityPersister::class)
->onlyMethods(['load', 'getClassMetadata'])
->disableOriginalConstructor()
->getMock();
$this->uowMock->setEntityPersister(ECommerceFeature::class, $persister);
Expand Down Expand Up @@ -153,8 +151,8 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void
*/
public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void
{
$persister = $this
->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load', 'getClassMetadata'])
$persister = $this->getMockBuilder(BasicEntityPersister::class)
->onlyMethods(['load', 'getClassMetadata'])
->disableOriginalConstructor()
->getMock();
$this->uowMock->setEntityPersister(ECommerceFeature::class, $persister);
Expand Down Expand Up @@ -192,8 +190,8 @@ public function testProxyClonesParentFields(): void

$classMetaData = $this->emMock->getClassMetadata(CompanyEmployee::class);

$persister = $this
->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load', 'getClassMetadata'])
$persister = $this->getMockBuilder(BasicEntityPersister::class)
->onlyMethods(['load', 'getClassMetadata'])
->disableOriginalConstructor()
->getMock();
$this->uowMock->setEntityPersister(CompanyEmployee::class, $persister);
Expand Down
9 changes: 4 additions & 5 deletions tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
use Doctrine\ORM\Query\QueryException;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools;
use PHPUnit\Framework\MockObject\MockObject;

class PaginatorTest extends OrmTestCase
{
use MockBuilderCompatibilityTools;

/** @var Connection&MockObject */
private $connection;
/** @var EntityManagerInterface&MockObject */
Expand All @@ -40,11 +37,13 @@ protected function setUp(): void
$driver->method('getDatabasePlatform')
->willReturn($platform);

$this->connection = $this->getMockBuilderWithOnlyMethods(Connection::class, ['executeQuery'])
$this->connection = $this->getMockBuilder(Connection::class)
->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driver])
->getMock();

$this->em = $this->getMockBuilderWithOnlyMethods(EntityManagerDecorator::class, ['newHydrator'])
$this->em = $this->getMockBuilder(EntityManagerDecorator::class)
->onlyMethods(['newHydrator'])
->setConstructorArgs([$this->createTestEntityManagerWithConnection($this->connection)])
->getMock();

Expand Down
6 changes: 2 additions & 4 deletions tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use Doctrine\Tests\Models\Forum\ForumAvatar;
use Doctrine\Tests\Models\Forum\ForumUser;
use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools;
use PHPUnit\Framework\MockObject\MockObject;
use stdClass;

Expand All @@ -46,8 +45,6 @@
*/
class UnitOfWorkTest extends OrmTestCase
{
use MockBuilderCompatibilityTools;

/**
* SUT
*/
Expand Down Expand Up @@ -610,7 +607,8 @@ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails(
->willReturn($platform);

// Set another connection mock that fail on commit
$this->connection = $this->getMockBuilderWithOnlyMethods(Connection::class, ['commit'])
$this->connection = $this->getMockBuilder(Connection::class)
->onlyMethods(['commit'])
->setConstructorArgs([[], $driver])
->getMock();
$this->_emMock = EntityManagerMock::create($this->connection, null, $this->eventManager);
Expand Down

This file was deleted.

0 comments on commit 7e20e97

Please sign in to comment.