| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Profiler\ProfilingContext; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class ProfilingContextTest extends PHPUnit\Framework\TestCase { |
| 28 |
|
| 29 |
use MediaWikiCoversValidator; |
| 30 |
|
| 31 |
public static function provideEntryPointNames() { |
| 32 |
return [ |
| 33 |
[ 'index', 'edit', 'index_edit' ], |
| 34 |
[ 'index', 'Recentchanges', 'index_Recentchanges' ], |
| 35 |
[ 'api', 'upload', 'api_upload' ], |
| 36 |
[ 'rest', '/wikibase/v1/something/{complex}/id', 'rest__wikibase_v1_something_complex_id' ] |
| 37 |
]; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public function testSetEntryPointHandler( $entryPoint, $handler, $metricName ) { |
| 44 |
$profilerContext = new ProfilingContext(); |
| 45 |
|
| 46 |
$this->assertFalse( $profilerContext->isInitialized() ); |
| 47 |
$profilerContext->init( $entryPoint, $handler ); |
| 48 |
|
| 49 |
$this->assertTrue( $profilerContext->isInitialized() ); |
| 50 |
$this->assertSame( $entryPoint, $profilerContext->getEntryPoint() ); |
| 51 |
$this->assertSame( $handler, $profilerContext->getHandler() ); |
| 52 |
$this->assertSame( $metricName, $profilerContext->getHandlerMetricPrefix() ); |
| 53 |
} |
| 54 |
} |