|
5 | 5 | use PHPUnit\Framework\TestCase;
|
6 | 6 | use Solarium\Component\ComponentAwareQueryInterface;
|
7 | 7 | use Solarium\Component\Highlighting\Highlighting;
|
| 8 | +use Solarium\Component\QueryInterface; |
8 | 9 | use Solarium\Component\QueryTraits\GroupingTrait;
|
9 | 10 | use Solarium\Component\QueryTraits\TermsTrait;
|
10 | 11 | use Solarium\Component\Result\Grouping\FieldGroup;
|
|
57 | 58 | use Solarium\QueryType\Update\RequestBuilder\Xml as XmlUpdateRequestBuilder;
|
58 | 59 | use Solarium\Support\Utility;
|
59 | 60 | use Solarium\Tests\Integration\Plugin\EventTimer;
|
| 61 | +use Solarium\Tests\Integration\Query\CustomQueryInterfaceQuery; |
| 62 | +use Solarium\Tests\Integration\Query\CustomSelfQuery; |
| 63 | +use Solarium\Tests\Integration\Query\CustomStaticQuery; |
60 | 64 | use Symfony\Contracts\EventDispatcher\Event;
|
61 | 65 |
|
62 | 66 | abstract class AbstractTechproductsTestCase extends TestCase
|
@@ -5066,6 +5070,32 @@ public function testEventDispatching()
|
5066 | 5070 |
|
5067 | 5071 | self::$client->removePlugin('eventtimer');
|
5068 | 5072 | }
|
| 5073 | + |
| 5074 | + /** |
| 5075 | + * Test the various return types that are valid for custom query classes that |
| 5076 | + * override the {@see \Solarium\Component\QueryTrait::setQuery()} method. |
| 5077 | + * |
| 5078 | + * If this test throws a fatal error, the return type of the parent might no |
| 5079 | + * longer be backward compatible with existing code that overrides it. |
| 5080 | + * |
| 5081 | + * @see https://github.com/solariumphp/solarium/issues/1097 |
| 5082 | + * |
| 5083 | + * @dataProvider customQueryClassProvider |
| 5084 | + */ |
| 5085 | + public function testCustomQueryClassSetQueryReturnType(string $queryClass) |
| 5086 | + { |
| 5087 | + $query = new $queryClass(); |
| 5088 | + $this->assertInstanceOf(QueryInterface::class, $query->setQuery('*:*')); |
| 5089 | + } |
| 5090 | + |
| 5091 | + public function customQueryClassProvider(): array |
| 5092 | + { |
| 5093 | + return [ |
| 5094 | + [CustomStaticQuery::class], |
| 5095 | + [CustomSelfQuery::class], |
| 5096 | + [CustomQueryInterfaceQuery::class], |
| 5097 | + ]; |
| 5098 | + } |
5069 | 5099 | }
|
5070 | 5100 |
|
5071 | 5101 | class GroupingTestQuery extends SelectQuery
|
|
0 commit comments