Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / search / SearchEventIngressSpyTrait.php
blob47b65d5e0b01e31292d972cd08b2a88a8db021e5
1 <?php
3 namespace MediaWiki\Tests\Search;
5 use SearchEngine;
6 use SearchEngineFactory;
8 /**
9 * Trait providing test spies for asserting that listeners in
10 * SearchEventIngress do or do not get called during
11 * certain actions.
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(
17 SearchEngine::class,
18 [ 'supports' ]
21 $searchEngine->method( 'supports' )->willReturn( false );
23 $searchEngineFactory = $this->createNoOpMock(
24 SearchEngineFactory::class,
25 [ 'create' ]
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 );