Debian Codegraph @

tests/phpunit/includes/profiler/ProfilingContextTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Profiler\ProfilingContext;
4
5 /**
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 */
23
24 /**
25 * @covers \MediaWiki\Profiler\ProfilingContext
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 * @dataProvider provideEntryPointNames
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 }