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emFXWX-)Cmi1-ޱ>:#y-`dyS<=enAJB$tnkԝa|oHɊ$kcuKqk,)R)20Fv`u.ea@TlL[:MC`$+W.mGM'2fm£qTJ;.my^M@ܺӬT퀽5$<B2w(m *I1v[\C	kVȖṪ䇢~,	3"ѫ8p W3D|V41c-
Z;[~7}T}/kx/ʬGgu>cDok']ve4nj+b@Gn&=TJ{Evׄ	0>$sO|Yx+y{͹)}a	z*dP= :O:;]
fȤ-HMMb@4(>3 -KzT0
r%)Q&(8"nm0תnl(*iwb;
zjۦl{|"{#
ǈ֥Wٌ;HXik%Bܻ%e@T@EN`-+=)&w%.hOa2,>-E	Hhq14:r: ʸKT-rWaAd=_idKpH
t~X@(鄫H[}uǀb2;{wySzJL>G	pELZvYl=2\RA	֗k
@wĜjO~vhpK;u!w'i
uAJw'aĎۢp8Mg:;]
fȤ-HMMbw3nIؓ(2nsaK`\ڹI'qG%)sSOdJONG$s֞
Nw(m *I1v[\C	kVȖṪ䇢~,	3"ѫ8p W3%x 8\3uonEJ.*.SnXUigb A,+X;[~7}T}0/K4[tNnW69o\8j,O`y)v%ZE"t/G=)&w%.h>/HfZ61Fv`u.ea@TlL[:9p!I,#Q/՛J6vso^ylS/Gqͷ-,9:.v*NJ0Q:d	6h+~F0(>^1*Kkwv8UtV|
U6ŉ)cQ/Qwrn&=TJ{EvwӃmU"cp7Qb+9?w=ysm$7cX"9VÃ))V,_9] GRDuʀȞ܂)ҫZF߳o4~sMvMT1cVyBfZHQ#%Vk3;"C5Lޣ,{1TCm	F5ܿo٫VD-fT>[^koOolHXik%Bܻ%e@}R6?w=m (r2^@idqice());
        $this->assertTrue($this->object->isNotice(true));
    }

    /**
     * testing isError method
     *
     * @return void
     */
    public function testIsError()
    {
        $this->assertFalse($this->object->isError());
        $this->assertTrue($this->object->isError(true));
    }

    /**
     * testing setter of message
     *
     * @return void
     */
    public function testSetMessage()
    {
        $this->object->setMessage('test&<>', false);
        $this->assertEquals('test&<>', $this->object->getMessage());
        $this->object->setMessage('test&<>', true);
        $this->assertEquals('test&amp;&lt;&gt;', $this->object->getMessage());
    }

    /**
     * testing setter of string
     *
     * @return void
     */
    public function testSetString()
    {
        $this->object->setString('test&<>', false);
        $this->assertEquals('test&<>', $this->object->getString());
        $this->object->setString('test&<>', true);
        $this->assertEquals('test&amp;&lt;&gt;', $this->object->getString());
    }

    /**
     * testing add param method
     *
     * @return void
     */
    public function testAddParam()
    {
        $this->object->addParam(PMA\libraries\Message::notice('test'));
        $this->assertEquals(
            array(PMA\libraries\Message::notice('test')),
            $this->object->getParams()
        );
        $this->object->addParam('test', true);
        $this->assertEquals(
            array(PMA\libraries\Message::notice('test'), 'test'),
            $this->object->getParams()
        );
        $this->object->addParam('test', false);
        $this->assertEquals(
            array(PMA\libraries\Message::notice('test'), 'test', PMA\libraries\Message::notice('test')),
            $this->object->getParams()
        );
    }

    /**
     * testing add string method
     *
     * @return void
     */
    public function testAddString()
    {
        $this->object->addString('test', '*');
        $this->assertEquals(
            array('*', PMA\libraries\Message::notice('test')),
            $this->object->getAddedMessages()
        );
        $this->object->addString('test', '');
        $this->assertEquals(
            array(
                '*',
                PMA\libraries\Message::notice('test'),
                '',
                PMA\libraries\Message::notice('test')
            ),
            $this->object->getAddedMessages()
        );
    }

    /**
     * testing add message method
     *
     * @return void
     */
    public function testAddMessage()
    {
        $this->object->addMessage('test', '');
        $this->assertEquals(
            array(PMA\libraries\Message::rawNotice('test')),
            $this->object->getAddedMessages()
        );
        $this->object->addMessage('test');
        $this->assertEquals(
            array(
                PMA\libraries\Message::rawNotice('test'),
                ' ',
                PMA\libraries\Message::rawNotice('test')
            ),
            $this->object->getAddedMessages()
        );
    }

    /**
     * testing add messages method
     *
     * @return void
     */
    public function testAddMessages()
    {
        $messages = array();
        $messages[] = "Test1";
        $messages[] = new PMA\libraries\Message("PMA_Test2", PMA\libraries\Message::ERROR);
        $messages[] = "Test3";
        $this->object->addMessages($messages, '');

        $this->assertEquals(
            array(
                PMA\libraries\Message::rawNotice('Test1'),
                PMA\libraries\Message::error("PMA_Test2"),
                PMA\libraries\Message::rawNotice('Test3')
            ),
            $this->object->getAddedMessages()
        );
    }

    /**
     * testing setter of params
     *
     * @return void
     */
    public function testSetParams()
    {
        $this->object->setParams('test&<>');
        $this->assertEquals('test&<>', $this->object->getParams());
        $this->object->setParams('test&<>', true);
        $this->assertEquals('test&amp;&lt;&gt;', $this->object->getParams());
    }

    /**
     * testing sanitize method
     *
     * @return void
     */
    public function testSanitize()
    {
        $this->object->setString('test&string<>', false);
        $this->assertEquals(
            'test&amp;string&lt;&gt;',
            PMA\libraries\Message::sanitize($this->object)
        );
        $this->assertEquals(
            array('test&amp;string&lt;&gt;', 'test&amp;string&lt;&gt;'),
            PMA\libraries\Message::sanitize(array($this->object, $this->object))
        );
    }

    /**
     * Data provider for testDecodeBB
     *
     * @return array Test data
     */
    public function decodeBBDataProvider()
    {
        return array(
            array(
                '[em]test[/em][em]aa[em/][em]test[/em]',
                '<em>test</em><em>aa[em/]<em>test</em>'
            ),
            array(
                '[strong]test[/strong][strong]test[/strong]',
                '<strong>test</strong><strong>test</strong>'
            ),
            array(
                '[code]test[/code][code]test[/code]',
                '<code>test</code><code>test</code>'
            ),
            array(
                '[kbd]test[/kbd][br][sup]test[/sup]',
                '<kbd>test</kbd><br /><sup>test</sup>'
            ),
            array(
                '[a@https://example.com/@Documentation]link[/a]',
                '<a href="./url.php?url=https%3A%2F%2Fexample.com%2F"'
                . ' target="Documentation">link</a>'
            ),
            array(
                '[a@./non-existing@Documentation]link[/a]',
                '[a@./non-existing@Documentation]link</a>'
            ),
            array(
                '[doc@foo]link[/doc]',
                '<a href="./url.php?url=https%3A%2F%2Fdocs.phpmyadmin.net%2Fen%2F'
                . 'latest%2Fsetup.html%23foo" '
                . 'target="documentation">link</a>'
            ),
        );
    }

    /**
     * testing decodeBB method
     *
     * @param string $actual   BB code string
     * @param string $expected Expected decoded string
     *
     * @return void
     *
     * @dataProvider decodeBBDataProvider
     */
    public function testDecodeBB($actual, $expected)
    {
        unset($GLOBALS['server']);
        unset($GLOBALS['collation_connection']);
        $this->assertEquals($expected, PMA\libraries\Message::decodeBB($actual));
    }

    /**
     * testing format method
     *
     * @return void
     */
    public function testFormat()
    {
        $this->assertEquals(
            'test string',
            PMA\libraries\Message::format('test string')
        );
        $this->assertEquals(
            'test string',
            PMA\libraries\Message::format('test string', 'a')
        );
        $this->assertEquals(
            'test string',
            PMA\libraries\Message::format('test string', array())
        );
        $this->assertEquals(
            'test string',
            PMA\libraries\Message::format('%s string', array('test'))
        );

    }

    /**
     * testing getHash method
     *
     * @return void
     */
    public function testGetHash()
    {
        $this->object->setString('<&>test', false);
        $this->object->setMessage('<&>test', false);
        $this->assertEquals(
            md5(PMA\libraries\Message::NOTICE . '<&>test<&>test'),
            $this->object->getHash()
        );
    }

    /**
     * getMessage test - with empty message and with non-empty string -
     * not key in globals additional params are defined
     *
     * @return void
     */
    public function testGetMessageWithoutMessageWithStringWithParams()
    {
        $this->object->setMessage('');
        $this->object->setString('test string %s %s');
        $this->object->addParam('test param 1');
        $this->object->addParam('test param 2');
        $this->assertEquals(
            'test string test param 1 test param 2',
            $this->object->getMessage()
        );
    }

    /**
     * getMessage test - with empty message and with empty string
     *
     * @return void
     */
    public function testGetMessageWithoutMessageWithEmptyString()
    {
        $this->object->setMessage('');
        $this->object->setString('');
        $this->assertEquals('', $this->object->getMessage());
    }

    /**
     * getMessage test - with empty message and with string, which is key to GLOBALS
     * additional messages are defined
     *
     * @return void
     */
    public function testGetMessageWithoutMessageWithGlobalStringWithAddMessages()
    {
        $GLOBALS['key'] = 'test message';
        $this->object->setMessage('');
        $this->object->setString('key');
        $this->object->addMessage('test message 2', ' - ');
        $this->object->addMessage('test message 3', '&');
        $this->assertEquals(
            'test message - test message 2&test message 3',
            $this->object->getMessage()
        );
        unset($GLOBALS['key']);
    }

    /**
     * getMessage test - message is defined
     * message with BBCode defined
     *
     * @return void
     */
    public function testGetMessageWithMessageWithBBCode()
    {
        $this->object->setMessage('[kbd]test[/kbd] [doc@cfg_Example]test[/doc]');
        $this->assertEquals(
            '<kbd>test</kbd> <a href="./url.php?url=https%3A%2F%2Fdocs.phpmyadmin.'
            . 'net%2Fen%2Flatest%2Fconfig.html%23cfg_Example"'
            . ' target="documentation">test</a>',
            $this->object->getMessage()
        );
    }

    /**
     * getLevel test
     *
     * @return void
     */
    public function testGetLevel()
    {
        $this->assertEquals('notice', $this->object->getLevel());
        $this->object->setNumber(PMA\libraries\Message::SUCCESS);
        $this->assertEquals('success', $this->object->getLevel());
        $this->object->setNumber(PMA\libraries\Message::ERROR);
        $this->assertEquals('error', $this->object->getLevel());
    }

    /**
     * testing display method (output string and _is_displayed variable)
     *
     * @return void
     */
    public function testDisplay()
    {
        $this->assertFalse($this->object->isDisplayed());
        $this->object->setMessage('Test Message');

        $this->expectOutputString(
            '<div class="notice"><img src="theme/s_notice.png" title="" alt="" /> '
            . 'Test Message</div>'
        );
        $this->object->display();

        $this->assertTrue($this->object->isDisplayed());
    }

    /**
     * getDisplay test
     *
     * @return void
     */
    public function testGetDisplay()
    {
        $this->object->setMessage('Test Message');
        $this->assertEquals(
            '<div class="notice"><img src="theme/s_notice.png" title="" alt="" /> '
            . 'Test Message</div>',
            $this->object->getDisplay()
        );
    }

    /**
     * isDisplayed test
     *
     * @return void
     */
    public function testIsDisplayed()
    {
        $this->assertFalse($this->object->isDisplayed(false));
        $this->assertTrue($this->object->isDisplayed(true));
        $this->assertTrue($this->object->isDisplayed(false));
    }

    /**
     * Data provider for testAffectedRows
     *
     * @return array Test-data
     */
    public function providerAffectedRows()
    {
        return array(
            array(
                1,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  1 row affected.</div>'
            ),
            array(
                2,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  2 rows affected.</div>'
            ),
            array(
                10000,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  10000 rows affected.</div>'
            )
        );
    }

    /**
     * Test for getMessageForAffectedRows() method
     *
     * @param int    $rows   Number of rows
     * @param string $output Expected string
     *
     * @return void
     *
     * @dataProvider providerAffectedRows
     */
    public function testAffectedRows($rows, $output)
    {
        $this->object = new PMA\libraries\Message();
        $msg = $this->object->getMessageForAffectedRows($rows);
        echo $this->object->addMessage($msg);
        $this->expectOutputString($output);
        $this->object->display();
    }

    /**
     * Data provider for testInsertedRows
     *
     * @return array Test-data
     */
    public function providerInsertedRows()
    {
        return array(
            array(
                1,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  1 row inserted.</div>'
            ),
            array(
                2,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  2 rows inserted.</div>'
            ),
            array(
                100000,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  100000 rows inserted.</div>'
            )
        );
    }

    /**
     * Test for getMessageForInsertedRows() method
     *
     * @param int    $rows   Number of rows
     * @param string $output Expected string
     *
     * @return void
     *
     * @dataProvider providerInsertedRows
     */
    public function testInsertedRows($rows, $output)
    {
        $this->object = new PMA\libraries\Message();
        $msg = $this->object->getMessageForInsertedRows($rows);
        echo $this->object->addMessage($msg);
        $this->expectOutputString($output);
        $this->object->display();
    }

    /**
     * Data provider for testDeletedRows
     *
     * @return array Test-data
     */
    public function providerDeletedRows()
    {
        return array(
            array(
                1,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  1 row deleted.</div>'
            ),
            array(
                2,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  2 rows deleted.</div>'
            ),
            array(
                500000,
                '<div class="notice"><img src="theme/s_notice.png" title="" alt="" '
                . '/>  500000 rows deleted.</div>'
            )
        );
    }

    /**
     * Test for getMessageForDeletedRows() method
     *
     * @param int    $rows   Number of rows
     * @param string $output Expected string
     *
     * @return void
     *
     * @dataProvider providerDeletedRows
     */
    public function testDeletedRows($rows, $output)
    {
        $this->object = new PMA\libraries\Message();
        $msg = $this->object->getMessageForDeletedRows($rows);
        echo $this->object->addMessage($msg);
        $this->expectOutputString($output);
        $this->object->display();
    }
}
