Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forgotten exception throws #10489

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function addEntityNamespace($alias, $namespace)
$alias
);
} else {
NotSupported::createForPersistence3(sprintf(
throw NotSupported::createForPersistence3(sprintf(
'Using short namespace alias "%s" by calling %s',
$alias,
__METHOD__
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ public function getRepository($entityName)
$entityName
);
} else {
NotSupported::createForPersistence3(sprintf(
throw NotSupported::createForPersistence3(sprintf(
'Using short namespace alias "%s" when calling %s',
$entityName,
__METHOD__
Expand Down
8 changes: 7 additions & 1 deletion tests/Doctrine/Tests/ORM/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\Psr6\CacheAdapter;
use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use Doctrine\ORM\Cache\CacheConfiguration;
use Doctrine\ORM\Cache\Exception\MetadataCacheNotConfigured;
Expand All @@ -17,6 +18,7 @@
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Exception\InvalidEntityRepository;
use Doctrine\ORM\Exception\NotSupported;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Exception\ProxyClassesAlwaysRegenerating;
use Doctrine\ORM\Mapping as AnnotationNamespace;
Expand Down Expand Up @@ -128,7 +130,11 @@ public function testNewDefaultAnnotationDriverWithSimpleAnnotationReader(): void

public function testSetGetEntityNamespace(): void
{
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818');
if (class_exists(PersistentObject::class)) {
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818');
} else {
$this->expectException(NotSupported::class);
}

$this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__);
self::assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace'));
Expand Down
10 changes: 10 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\Tests\ORM\Functional;

use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\ORM\Query;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsAddressDTO;
Expand All @@ -13,6 +14,7 @@
use Doctrine\Tests\Models\CMS\CmsUserDTO;
use Doctrine\Tests\OrmFunctionalTestCase;

use function class_exists;
use function count;

/** @group DDC-1574 */
Expand Down Expand Up @@ -208,6 +210,10 @@ public function testShouldAssumeFromEntityNamespaceWhenNotGiven(): void

public function testShouldSupportFromEntityNamespaceAlias(): void
{
if (! class_exists(PersistentObject::class)) {
self::markTestSkipped('This test requires doctrine/persistence 2');
}

$dql = '
SELECT
new CmsUserDTO(u.name, e.email, a.city)
Expand Down Expand Up @@ -235,6 +241,10 @@ public function testShouldSupportFromEntityNamespaceAlias(): void

public function testShouldSupportValueObjectNamespaceAlias(): void
{
if (! class_exists(PersistentObject::class)) {
self::markTestSkipped('This test requires doctrine/persistence 2');
}

$dql = '
SELECT
new cms:CmsUserDTO(u.name, e.email, a.city)
Expand Down
5 changes: 5 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\Tests\ORM\Functional;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\DBAL\Logging\Middleware as LoggingMiddleware;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\NonUniqueResultException;
Expand Down Expand Up @@ -557,6 +558,10 @@ public function testModifiedLimitQuery(): void

public function testSupportsQueriesWithEntityNamespaces(): void
{
if (! class_exists(PersistentObject::class)) {
self::markTestSkipped('This test requires doctrine/persistence 2');
}

$this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS');

try {
Expand Down
11 changes: 11 additions & 0 deletions tests/Doctrine/Tests/ORM/Query/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\Tests\ORM\Query;

use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
Expand All @@ -12,6 +13,8 @@
use Doctrine\Tests\OrmTestCase;
use stdClass;

use function class_exists;

class ParserTest extends OrmTestCase
{
/**
Expand Down Expand Up @@ -53,6 +56,10 @@ public function testAbstractSchemaNameSupportsIdentifier(): void
*/
public function testAbstractSchemaNameSupportsNamespaceAlias(): void
{
if (! class_exists(PersistentObject::class)) {
self::markTestSkipped('This test requires doctrine/persistence 2');
}

$parser = $this->createParser('CMS:CmsUser');

$parser->getEntityManager()->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS');
Expand All @@ -66,6 +73,10 @@ public function testAbstractSchemaNameSupportsNamespaceAlias(): void
*/
public function testAbstractSchemaNameSupportsNamespaceAliasWithRelativeClassname(): void
{
if (! class_exists(PersistentObject::class)) {
self::markTestSkipped('This test requires doctrine/persistence 2');
}

$parser = $this->createParser('Model:CMS\CmsUser');

$parser->getEntityManager()->getConfiguration()->addEntityNamespace('Model', 'Doctrine\Tests\Models');
Expand Down