Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
91.67% covered (success)
91.67%
11 / 12
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
MockEnv
91.67% covered (success)
91.67%
11 / 12
50.00% covered (danger)
50.00%
1 / 2
4.01
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
3
 bumpParserResourceUse
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\Mocks;
5
6use Wikimedia\Parsoid\Config\Env;
7use Wikimedia\Parsoid\Config\PageContent;
8use Wikimedia\Parsoid\Config\StubMetadataCollector;
9
10class MockEnv extends Env {
11    /**
12     * @param array $opts
13     *  - log: (bool) Whether the logger should log. Default false.
14     *  - wrapSections: (bool) Whether to wrap sections. Default false.
15     *  - pageConfig: (PageConfig) If given, supplies a custom PageConfig instance to use.
16     *  - siteConfig: (SiteConfig) If given, supplies a custom SiteConfig instance to use.
17     *  - dataAccess: (DataAccess) If given, supplies a custom DataAccess instance to use.
18     *  - pageContent: (PageContent|string) If given and 'pageConfig' is not, this is passed to the
19     *    MockPageConfig.
20     */
21    public function __construct( array $opts ) {
22        $siteConfig = $opts['siteConfig'] ?? new MockSiteConfig( $opts );
23        if ( isset( $opts['pageConfig'] ) ) {
24            $pageConfig = $opts['pageConfig'];
25        } else {
26            $content = $opts['pageContent'] ?? 'Some dummy source wikitext for testing.';
27            $pageContent = $content instanceof PageContent
28                ? $content
29                : new MockPageContent( [ 'main' => $content ] );
30            $pageConfig = new MockPageConfig( $siteConfig, $opts, $pageContent );
31        }
32        $dataAccess = $opts['dataAccess'] ?? new MockDataAccess( $siteConfig, $opts );
33        $metadata = new StubMetadataCollector( $siteConfig );
34        parent::__construct( $siteConfig, $pageConfig, $dataAccess, $metadata, $opts );
35    }
36
37    /**
38     * @suppress PhanEmptyPublicMethod
39     * @param string $resource
40     * @param int $count
41     */
42    public function bumpParserResourceUse( string $resource, int $count = 1 ): void {
43    }
44}