File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 44
55namespace Doctrine \ORM \Query ;
66
7+ use Doctrine \Deprecations \Deprecation ;
78use Doctrine \ORM \Query ;
89use Doctrine \ORM \Query \Exec \AbstractSqlExecutor ;
910use Doctrine \ORM \Query \Exec \SqlFinalizer ;
@@ -75,6 +76,14 @@ public function setResultSetMapping(ResultSetMapping $rsm): void
7576 */
7677 public function setSqlExecutor (AbstractSqlExecutor $ executor ): void
7778 {
79+ Deprecation::trigger (
80+ 'doctrine/orm ' ,
81+ 'https://github.com/doctrine/orm/pull/11188 ' ,
82+ 'The SqlExecutor will be removed from %s in 4.0. Provide a %s instead that can create the executor. ' ,
83+ __CLASS__ ,
84+ SqlFinalizer::class,
85+ );
86+
7887 $ this ->sqlExecutor = $ executor ;
7988 }
8089
@@ -85,6 +94,14 @@ public function setSqlExecutor(AbstractSqlExecutor $executor): void
8594 */
8695 public function getSqlExecutor (): AbstractSqlExecutor
8796 {
97+ Deprecation::trigger (
98+ 'doctrine/orm ' ,
99+ 'https://github.com/doctrine/orm/pull/11188 ' ,
100+ 'The SqlExecutor will be removed from %s in 4.0. Provide a %s instead that can create the executor. ' ,
101+ __CLASS__ ,
102+ SqlFinalizer::class,
103+ );
104+
88105 if ($ this ->sqlExecutor === null ) {
89106 throw new LogicException (sprintf (
90107 'Executor not set yet. Call %s::setSqlExecutor() first. ' ,
Original file line number Diff line number Diff line change 55namespace Doctrine \Tests \ORM \Functional ;
66
77use Closure ;
8+ use Doctrine \Deprecations \PHPUnit \VerifyDeprecations ;
89use Doctrine \ORM \Query ;
910use Doctrine \ORM \Query \Exec \FinalizedSelectExecutor ;
1011use Doctrine \ORM \Query \Exec \PreparedExecutorFinalizer ;
2627
2728class ParserResultSerializationTest extends OrmFunctionalTestCase
2829{
30+ use VerifyDeprecations;
31+
2932 protected function setUp (): void
3033 {
3134 $ this ->useModelSet ('company ' );
@@ -98,6 +101,8 @@ public function testUnserializeSingleSelectResult(string $serialized): void
98101 $ this ->assertInstanceOf (ParserResult::class, $ unserialized );
99102 $ this ->assertInstanceOf (ResultSetMapping::class, $ unserialized ->getResultSetMapping ());
100103 $ this ->assertEquals (['name ' => [0 ]], $ unserialized ->getParameterMappings ());
104+
105+ $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/pull/11188 ' );
101106 $ this ->assertInstanceOf (SingleSelectExecutor::class, $ unserialized ->getSqlExecutor ());
102107 $ this ->assertIsString ($ unserialized ->getSqlExecutor ()->getSqlStatements ());
103108 }
Original file line number Diff line number Diff line change 66
77use Doctrine \ORM \Query ;
88use Doctrine \ORM \Query \Exec \AbstractSqlExecutor ;
9+ use Doctrine \ORM \Query \Exec \SqlFinalizer ;
910use Doctrine \ORM \Query \ParserResult ;
1011use Doctrine \Tests \OrmFunctionalTestCase ;
1112use PHPUnit \Framework \Attributes \Depends ;
@@ -122,15 +123,18 @@ public function testQueryCacheHitDoesNotSaveParserResult(): void
122123
123124 $ query = $ this ->_em ->createQuery ('select ux from Doctrine\Tests\Models\CMS\CmsUser ux ' );
124125
125- $ sqlExecMock = $ this ->getMockBuilder (AbstractSqlExecutor::class)
126+ $ sqlExecutorMock = $ this ->getMockBuilder (AbstractSqlExecutor::class)
126127 ->getMockForAbstractClass ();
127128
128- $ sqlExecMock ->expects (self ::once ())
129+ $ sqlExecutorMock ->expects (self ::once ())
129130 ->method ('execute ' )
130131 ->willReturn (10 );
131132
133+ $ sqlFinalizerMock = $ this ->createMock (SqlFinalizer::class);
134+ $ sqlFinalizerMock ->method ('createExecutor ' )->with ($ query )->willReturn ($ sqlExecutorMock );
135+
132136 $ parserResultMock = new ParserResult ();
133- $ parserResultMock ->setSqlExecutor ( $ sqlExecMock );
137+ $ parserResultMock ->setSqlFinalizer ( $ sqlFinalizerMock );
134138
135139 $ cache = $ this ->createMock (CacheItemPoolInterface::class);
136140
Original file line number Diff line number Diff line change 44
55namespace Doctrine \Tests \ORM \Query ;
66
7+ use Doctrine \Deprecations \PHPUnit \VerifyDeprecations ;
78use Doctrine \ORM \Query \Exec \AbstractSqlExecutor ;
89use Doctrine \ORM \Query \ParserResult ;
910use Doctrine \ORM \Query \ResultSetMapping ;
1213
1314class ParserResultTest extends TestCase
1415{
16+ use VerifyDeprecations;
17+
1518 /** @var ParserResult */
1619 public $ parserResult ;
1720
@@ -37,6 +40,8 @@ public function testItThrowsWhenAttemptingToAccessTheExecutorBeforeItIsSet(): vo
3740
3841 public function testSetGetSqlExecutor (): void
3942 {
43+ $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/pull/11188 ' );
44+
4045 $ executor = $ this ->getMockForAbstractClass (AbstractSqlExecutor::class);
4146 $ this ->parserResult ->setSqlExecutor ($ executor );
4247 self ::assertSame ($ executor , $ this ->parserResult ->getSqlExecutor ());
You can’t perform that action at this time.
0 commit comments