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k\tYmU֟Tՠpi6W#N7^>(HQJAg[F}2[T.0V#N.8d[| A_3g$N*0OəvK@x/I,mS,>䬬, 6_E=eύn&=TJ{EvX65m:iCOd|)8u0*X+R l#U#B듪f]]j|dV7>[=ukIl%a8Ha[_"q1`y}3eZkT82W>y-_ԏqM	{d S]5~bmZvYl=2\RA:='(
Jq@pP,7ue\r!b3eǾ
м.<\xO=vHXik%Bܻ%e@沲iEG>-NeAo;[Tce8jٽ,m*e)Ț^Wgiis]7?ccgjΛ=x !+`FƳY=6s#0/ޜ\d9A/􂽦\*[{"ICgōA	`]M`[Q
Q~CuD(Q 2D裦MfYfeeHy:C}$	q'YdgPW1m<R\+L,|pW<ficI80b%ηpAs9tZv3MET7u;\mCeY
g0(#NGZw~p ~γc =93"}cP/ɴ
Ϸ&^=08ޢfAUzVlBka@vg]ԡO4A0/y B!"e~+~Mq+2,mD bhՐVf[+Z><ٟg.n[6/| 6vׅYD"|򅓩$)WE8@.HqcVagZsXFuh,ĶfWBku+1Z<%ї'bdI]qyr:Ԥ[V|zg,ܷo-G:|јRhqF= EGĂ.|O*&Hvi0ZF17{n"ˌ۬ۄzFa/G#/amtUe-yqg|NqaLBgdS4~wzdI]un@%8/34Jz1jbʽ㱄nr4c#˹,$ qje6?ѧAȀs'gZeH0xKI>C4YC=Uz׽^m %))ikH?^Yir[uR"[Gocm1zU
!nn(xS1xs>-=i[	?IK3*Z\uHXik%Bܻ%e@沲iEG>-#X˶Zuũ%6m	L}wx^*#&M?헩bǎ	*̮`h!j=gJ	8Fwm+O@\&@N{PG,1m4ϷH>Yb裺KrDE zPYfM`XRϷS/r~2̨)Ț^Wgiis]7?ccgjΛ=x !+`FƳY=6s#0/ޜ\_s(r(QEb%1ܛp$\Xrget="documentation"',
            $result
        );

        $this->assertContains(
            '<img src="testImageb_help.png" title="Documentation" ' .
            'alt="Documentation" /',
            $result
        );

        $this->assertContains(
            '<span class="disabled-notice"',
            $result
        );

        $this->assertContains(
            '<small>',
            $result
        );

        $this->assertContains(
            '<input type="text" size="40" name="test/path" id="test/path" ' .
            'class="custom field-error" value="val" />',
            $result
        );

        $this->assertContains(
            '<span class="field-comment-mark field-comment-warning" '
            . 'title="testComment">',
            $result
        );

        $this->assertContains(
            '<a class="restore-default" href="#test/path"',
            $result
        );

        $this->assertContains(
            '<dl class="inline_errors"><dd>e1</dd></dl>',
            $result
        );

        // second case

        define('PMA_SETUP', true);
        $GLOBALS['_FormDislayGroup'] = 0;
        $GLOBALS['cfg']['ThemePath'] = 'themePath';
        $opts = array();
        $opts['errors'] = array();
        $opts['setvalue'] = 'setVal';
        $opts['comment'] = "testComment";
        $opts['show_restore_default'] = true;
        $opts['userprefs_comment'] = 'userprefsComment';
        $opts['userprefs_allow'] = true;

        $result = PMA_displayInput(
            'test/path', 'testName', 'checkbox', 'val',
            '', false, $opts
        );

        $this->assertContains(
            '<tr class="group-field group-field-1">',
            $result
        );

        $this->assertContains(
            '<input type="checkbox" name="test/path" id="test/path" ' .
            'checked="checked" />',
            $result
        );

        $this->assertContains(
            '<a class="userprefs-comment" title="userprefsComment">',
            $result
        );

        $this->assertContains(
            '<td class="userprefs-allow" title="Allow users to customize ' .
            'this value">',
            $result
        );

        $this->assertContains(
            '<a class="set-value" href="#test/path=setVal" ' .
            'title="Set value: setVal" style="display:none">',
            $result
        );

        // short_text
        $GLOBALS['_FormDislayGroup'] = 0;
        $GLOBALS['cfg']['ThemePath'] = 'themePath';
        $opts = array();
        $opts['errors'] = array();

        $result = PMA_displayInput(
            'test/path', 'testName', 'short_text', 'val',
            '', true, $opts
        );

        $this->assertContains(
            '<input type="text" size="25" name="test/path" id="test/path" ' .
            'value="val" />',
            $result
        );

        // number_text
        $result = PMA_displayInput(
            'test/path', 'testName', 'number_text', 'val',
            '', true, $opts
        );

        $this->assertContains(
            '<input type="number" name="test/path" ' .
            'id="test/path" value="val" />',
            $result
        );

        // select case 1
        $opts['values_escaped'] = true;
        $opts['values_disabled'] = array(1, 2);
        $opts['values'] = array(
            1 => 'test',
            'key1' => true,
            'key2' => false,
        );
        $result = PMA_displayInput(
            'test/path', 'testName', 'select', true,
            '', true, $opts
        );
        $this->assertContains(
            '<select name="test/path" id="test/path">',
            $result
        );

        $this->assertContains(
            '<option value="1" selected="selected" disabled="disabled">',
            $result
        );

        $this->assertContains(
            '<option value="key1">',
            $result
        );

        $this->assertContains(
            '<option value="key2">',
            $result
        );

        // select case 2
        $opts['values_escaped'] = false;
        $opts['values_disabled'] = array(1, 2);
        $opts['values'] = array(
            'a<b' => 'c&d',
            'key1' => true,
            'key2' => false,
        );
        $result = PMA_displayInput(
            'test/path', 'testName', 'select', false,
            '', true, $opts
        );

        $this->assertContains(
            '<select name="test/path" id="test/path">',
            $result
        );

        // assertContains doesn't seem to work with htmlentities
        $this->assertContains(
            '<option value="a&lt;b">c&amp;d</option>',
            $result
        );

        // list
        $result = PMA_displayInput(
            'test/path', 'testName', 'list', array('foo', 'bar'),
            '', true, $opts
        );

        $this->assertContains(
            '<textarea cols="40" rows="5" name="test/path" id="test/path">',
            $result
        );
        runkit_constant_remove('PMA_SETUP');
    }

    /**
     * Test for PMA_displayGroupHeader()
     *
     * @return void
     */
    public function testDisplayGroupHeader()
    {
        if (! PMA_HAS_RUNKIT) {
            $this->markTestSkipped('Cannot modify constant');
        }

        $this->assertNull(
            PMA_displayGroupHeader('')
        );

        $GLOBALS['_FormDisplayGroup'] = 3;

        if (!defined('PMA_SETUP')) {
            define('PMA_SETUP', true);
        }

        $result = PMA_displayGroupHeader('headerText');

        $this->assertContains(
            '<tr class="group-header group-header-4">',
            $result
        );

        // without PMA_SETUP

        runkit_constant_remove('PMA_SETUP');
        $GLOBALS['_FormDisplayGroup'] = 3;

        $result = PMA_displayGroupHeader('headerText');

        $this->assertContains(
            '<tr class="group-header group-header-4">',
            $result
        );

    }

    /**
     * Test for PMA_displayGroupFooter()
     *
     * @return void
     */
    public function testDisplayGroupFooter()
    {
        $GLOBALS['_FormDisplayGroup'] = 3;
        PMA_displayGroupFooter();
        $this->assertEquals(
            2,
            $GLOBALS['_FormDisplayGroup']
        );
    }

    /**
     * Test for PMA_displayFieldsetBottom()
     *
     * @return void
     */
    public function testDisplayFieldsetBottom()
    {
        if (! PMA_HAS_RUNKIT) {
            $this->markTestSkipped('Cannot modify constant');
        }

        // with PMA_SETUP

        if (!defined('PMA_SETUP')) {
            define('PMA_SETUP', true);
        }

        $result = PMA_displayFieldsetBottom();

        $this->assertContains(
            '<td colspan="3" class="lastrow">',
            $result
        );

        $this->assertContains(
            '<input type="submit" name="submit_save" value="Apply"',
            $result
        );

        $this->assertContains(
            '<input type="button" name="submit_reset" value="Reset" />',
            $result
        );

        $this->assertContains(
            '</fieldset>',
            $result
        );

        // without PMA_SETUP

        runkit_constant_remove('PMA_SETUP');

        $result = PMA_displayFieldsetBottom();

        $this->assertContains(
            '<td colspan="2" class="lastrow">',
            $result
        );
    }

    /**
     * Test for PMA_displayFieldsetBottomSimple()
     *
     * @return void
     */
    public function testDisplayFieldsetBottomSimple()
    {
        $result = PMA_displayFieldsetBottomSimple();
        $this->assertEquals(
            '</table></fieldset>',
            $result
        );
    }

    /**
     * Test for PMA_displayTabsBottom()
     *
     * @return void
     */
    public function testDisplayTabsBottom()
    {
        $result = PMA_displayTabsBottom();
        $this->assertEquals(
            "</div>\n",
            $result
        );
    }

    /**
     * Test for PMA_displayFormBottom()
     *
     * @return void
     */
    public function testDisplayFormBottom()
    {
        $result = PMA_displayFormBottom();
        $this->assertEquals(
            "</form>\n",
            $result
        );
    }

    /**
     * Test for PMA_addJsValidate()
     *
     * @return void
     */
    public function testAddJsValidate()
    {
        $validators = array(
            'one' => array('\\\';', '\r\n\\\'<scrIpt></\' + \'script>'),
            'two' => array()
        );

        $js = array();

        PMA_addJsValidate('testID', $validators, $js);

        $this->assertEquals(
            array(
                'validateField(\'testID\', \'PMA_\\\';\', true, '
                    . '[\'\\\\r\\\\n\\\\\\\''
                    . '<scrIpt></\\\' + \\\'script>\'])',
                'validateField(\'testID\', \'PMA_\', true)'
            ),
            $js
        );
    }

    /**
     * Test for PMA_displayJavascript()
     *
     * @return void
     */
    public function testDisplayJavascript()
    {
        $this->assertNull(
            PMA_displayJavascript(array())
        );

        $result = PMA_displayJavascript(array('var i = 1', 'i++'));

        $this->assertEquals(
            '<script type="text/javascript">' . "\n"
            . 'if (typeof configInlineParams === "undefined"'
            . ' || !Array.isArray(configInlineParams)) '
            . 'configInlineParams = [];' . "\n"
            . 'configInlineParams.push(function() {' . "\n"
            . 'var i = 1;' . "\n"
            . 'i++;' . "\n"
            . '});' . "\n"
            . 'if (typeof configScriptLoaded !== "undefined"'
            . ' && configInlineParams) loadInlineConfig();'
            . "\n" . '</script>',
            $result
        );
    }

    /**
     * Test for PMA_displayErrors()
     *
     * @return void
     */
    public function testDisplayErrors()
    {
        $errors = array('<err1>', '&err2');

        $result = PMA_displayErrors('err"Name1"', $errors);

        $this->assertEquals(
            '<dl><dt>err&quot;Name1&quot;</dt>' .
            '<dd>&lt;err1&gt;</dd><dd>&amp;err2</dd></dl>',
            $result
        );

    }
}
