3 namespace MediaWiki\Tests\Search
;
6 use SearchEngineFactory
;
9 * Trait providing test spies for asserting that listeners in
10 * SearchEventIngress do or do not get called during
13 trait SearchEventIngressSpyTrait
{
14 private function installSearchEventIngressSpys( int $searchEngineCreate ) {
15 // Make sure SearchEventIngress is triggered and tries to re-index the page
16 $searchEngine = $this->createNoOpMock(
21 $searchEngine->method( 'supports' )->willReturn( false );
23 $searchEngineFactory = $this->createNoOpMock(
24 SearchEngineFactory
::class,
28 // this is the relevant assertion:
29 $searchEngineFactory->expects( $this->exactly( $searchEngineCreate ) )
30 ->method( 'create' )->willReturn( $searchEngine );
32 $this->setService( 'SearchEngineFactory', $searchEngineFactory );
35 private function installSearchEventIngressSpyForEdit() {
36 $this->installSearchEventIngressSpys( 1 );
39 private function installSearchEventIngressSpyForDerived() {
40 $this->installSearchEventIngressSpys( 1 );
43 private function installSearchEventIngressSpyForPageMove() {
44 $this->installSearchEventIngressSpys( 2 );
47 private function installSearchEventIngressSpyForUndeletion() {
48 $this->installSearchEventIngressSpys( 1 );
51 private function installSearchEventIngressSpyForImport() {
52 $this->installSearchEventIngressSpys( 1 );