Example #1
0
 /**
  * @using runkit pecl extension
  * if not define PMA_USR_OS, then define it as Win
  * if installed runkit, then constant will not change
  */
 public function testWhichCrlf()
 {
     $runkit = function_exists('runkit_constant_redefine');
     if ($runkit && defined('PMA_USR_OS')) {
         $pma_usr_os = PMA_USR_OS;
     }
     if (defined('PMA_USR_OS') && !$runkit) {
         if (PMA_USR_OS == 'Win') {
             $this->assertEquals("\r\n", PMA_whichCrlf());
         } else {
             $this->assertEquals("\n", PMA_whichCrlf());
         }
         $this->markTestIncomplete('Cannot redefine constant');
     } else {
         if ($runkit) {
             define('PMA_USR_OS', 'Linux');
             $this->assertEquals("\n", PMA_whichCrlf());
         }
         if ($runkit) {
             runkit_constant_redefine('PMA_USR_OS', 'Win');
         } else {
             define('PMA_USR_OS', 'Win');
         }
         $this->assertEquals("\r\n", PMA_whichCrlf());
     }
     if ($runkit) {
         if (isset($pma_usr_os)) {
             runkit_constant_redefine('PMA_USR_OS', 'Win');
         } else {
             runkit_constant_remove('PMA_USR_OS');
         }
     }
 }
Example #2
0
 /**
  *	Reset original definition.
  */
 public static function resetConstant($constant)
 {
     $originalConstant = "__ORIGINAL_{$constant}";
     if (defined($originalConstant)) {
         runkit_constant_redefine($constant, constant($originalConstant));
         runkit_constant_remove($originalConstant);
     }
 }
 /**
  * Tear down
  *
  * @return void
  */
 public function tearDown()
 {
     //session_destroy();
     // cleaning constants
     if (PMA_HAS_RUNKIT) {
         if ($this->oldSIDvalue != 'non-defined') {
             runkit_constant_redefine('SID', $this->oldSIDvalue);
         } elseif (defined('SID')) {
             runkit_constant_remove('SID');
         }
     }
 }
 /**
  * Test for whichCrlf
  *
  * @return void
  *
  * @using runkit pecl extension
  * if not define PMA_USR_OS, then define it as Win
  * if installed runkit, then constant will not change
  */
 public function testWhichCrlf()
 {
     if (PMA_HAS_RUNKIT && defined('PMA_USR_OS')) {
         $pma_usr_os = PMA_USR_OS;
     }
     if (defined('PMA_USR_OS') && !PMA_HAS_RUNKIT) {
         if (PMA_USR_OS == 'Win') {
             $this->assertEquals("\r\n", PMA_Util::whichCrlf());
         } else {
             $this->assertEquals("\n", PMA_Util::whichCrlf());
         }
         $this->markTestIncomplete('Cannot redefine constant');
     } else {
         if (PMA_HAS_RUNKIT) {
             if (!defined('PMA_USR_OS')) {
                 define('PMA_USR_OS', 'Linux');
             } else {
                 runkit_constant_redefine('PMA_USR_OS', 'Linux');
             }
             $this->assertEquals("\n", PMA_Util::whichCrlf());
         }
         if (PMA_HAS_RUNKIT) {
             runkit_constant_redefine('PMA_USR_OS', 'Win');
         } else {
             define('PMA_USR_OS', 'Win');
         }
         $this->assertEquals("\r\n", PMA_Util::whichCrlf());
     }
     if (PMA_HAS_RUNKIT) {
         if (isset($pma_usr_os)) {
             runkit_constant_redefine('PMA_USR_OS', 'Win');
         } else {
             runkit_constant_remove('PMA_USR_OS');
         }
     }
 }
 /**
  * Test for PMA_checkConfigRw
  *
  * @return void
  */
 public function testPMACheckConfigRw()
 {
     if (!PMA_HAS_RUNKIT) {
         $this->markTestSkipped('Cannot redefine constant');
     }
     $redefine = null;
     $GLOBALS['cfg']['AvailableCharsets'] = array();
     $GLOBALS['server'] = 0;
     $GLOBALS['ConfigFile'] = new ConfigFile();
     if (!defined('SETUP_CONFIG_FILE')) {
         define('SETUP_CONFIG_FILE', 'test/test_data/configfile');
     } else {
         $redefine = 'SETUP_CONFIG_FILE';
         runkit_constant_redefine('SETUP_CONFIG_FILE', 'test/test_data/configfile');
     }
     $is_readable = false;
     $is_writable = false;
     $file_exists = false;
     PMA_checkConfigRw($is_readable, $is_writable, $file_exists);
     $this->assertTrue($is_readable);
     $this->assertTrue($is_writable);
     $this->assertFalse($file_exists);
     runkit_constant_redefine('SETUP_CONFIG_FILE', 'test/test_data/test.file');
     PMA_checkConfigRw($is_readable, $is_writable, $file_exists);
     $this->assertTrue($is_readable);
     $this->assertTrue($is_writable);
     $this->assertTrue($file_exists);
     if ($redefine !== null) {
         runkit_constant_redefine('SETUP_CONFIG_FILE', $redefine);
     } else {
         runkit_constant_remove('SETUP_CONFIG_FILE');
     }
 }
 /**
  * Test for AuthenticationConfig::authFails
  *
  * @return void
  */
 public function testAuthFails()
 {
     $removeConstant = false;
     $GLOBALS['error_handler'] = new PMA_Error_Handler();
     $GLOBALS['cfg']['Servers'] = array(1);
     $GLOBALS['allowDeny_forbidden'] = false;
     if (!defined('PMA_USR_BROWSER_AGENT')) {
         define('PMA_USR_BROWSER_AGENT', 'chrome');
         $removeConstant = true;
         if (!PMA_HAS_RUNKIT) {
             $this->markTestSkipped('Cannot remove constant');
         }
     }
     $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
     $GLOBALS['dbi'] = $dbi;
     ob_start();
     $result = $this->object->authFails();
     $html = ob_get_clean();
     $this->assertTrue($result);
     $this->assertContains('You probably did not create a configuration file. You might want ' . 'to use the <a href="setup/">setup script</a> to create one.', $html);
     $this->assertContains('<strong>MySQL said: </strong><a href="./url.php?url=http%3A%2F%2F' . 'dev.mysql.com%2Fdoc%2Frefman%2F5.6%2Fen%2Ferror-messages-server.html"' . ' target="mysql_doc">' . '<img src="themes/dot.gif" title="Documentation" alt="Documentation" ' . 'class="icon ic_b_help" /></a>', $html);
     $this->assertContains('Cannot connect: invalid settings.', $html);
     $this->assertContains('<a href="index.php?server=0&amp;lang=en' . '&amp;collation_connection=utf-8&amp;token=token" ' . 'class="button disableAjax">Retry to connect</a>', $html);
     if ($removeConstant) {
         runkit_constant_remove('PMA_USR_BROWSER_AGENT');
     }
 }
    public function tearDown()
    {
        //session_destroy();

        // cleaning constants
        if ($this->runkitExt) {

            if ($this->oldIISvalue != 'non-defined') {
                runkit_constant_redefine('PMA_IS_IIS', $this->oldIISvalue);
            } elseif (defined('PMA_IS_IIS')) {
                runkit_constant_remove('PMA_IS_IIS');
            }

            if ($this->oldSIDvalue != 'non-defined') {
                runkit_constant_redefine('SID', $this->oldSIDvalue);
            } elseif (defined('SID')) {
                runkit_constant_remove('SID');
            }
        }

        if ($this->apdExt) {
            unset($GLOBALS['header']);
        }
    }
 /**
  * Test for PMA_userprefsRedirect
  *
  * @return void
  */
 public function testUserprefsRedirect()
 {
     if (!defined('PMA_TEST_HEADERS')) {
         $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension');
     }
     $GLOBALS['PMA_Config']->set('PmaAbsoluteUri', '');
     $GLOBALS['cfg']['ServerDefault'] = 1;
     $GLOBALS['lang'] = '';
     $redefine = null;
     if (!defined('PMA_IS_IIS')) {
         define('PMA_IS_IIS', false);
     } else {
         $redefine = PMA_IS_IIS;
         runkit_constant_redefine('PMA_IS_IIS', false);
     }
     PMA_userprefsRedirect('file.html', array('a' => 'b'), 'h ash');
     $this->assertContains('Location: /phpmyadmin/file.html?a=b&saved=1&server=0#h+ash', $GLOBALS['header'][0]);
     if ($redefine !== null) {
         runkit_constant_redefine('PMA_IS_IIS', $redefine);
     } else {
         runkit_constant_remove('PMA_IS_IIS');
     }
 }
 /**
  * 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);
 }
Example #10
0
 public static function undefineConstant($className, $constName)
 {
     $runkitName = ($className === null ? "" : $className . "::") . $constName;
     yTest_debugCC("undefineConstant {$runkitName}");
     $res = runkit_constant_remove($runkitName);
     yTest_assert($res);
 }
 /**
  * Test for PMA_getDbCollation
  *
  * @return void
  * @test
  */
 public function testGetDbCollation()
 {
     if (!PMA_HAS_RUNKIT) {
         $this->markTestSkipped('Cannot redefine constant - missing runkit extension');
     } else {
         $GLOBALS['server'] = 1;
         // test case for system schema
         $this->assertEquals('utf8_general_ci', PMA_getDbCollation("information_schema"));
         $restoreDrizzle = '';
         // test case with no pma drizzle
         if (defined('PMA_DRIZZLE')) {
             $restoreDrizzle = PMA_DRIZZLE;
             runkit_constant_redefine('PMA_DRIZZLE', false);
         } else {
             $restoreDrizzle = 'PMA_TEST_CONSTANT_REMOVE';
             define('PMA_DRIZZLE', false);
         }
         $GLOBALS['cfg']['Server']['DisableIS'] = false;
         $GLOBALS['cfg']['DBG']['sql'] = false;
         $this->assertEquals('utf8_general_ci', PMA_getDbCollation('pma_test'));
         // test case with pma drizzle as true
         runkit_constant_redefine('PMA_DRIZZLE', true);
         $this->assertEquals('utf8_general_ci_pma_drizzle', PMA_getDbCollation('pma_test'));
         $GLOBALS['cfg']['Server']['DisableIS'] = true;
         $GLOBALS['db'] = 'pma_test2';
         $this->assertEquals('bar', PMA_getDbCollation('pma_test'));
         $this->assertNotEquals('pma_test', $GLOBALS['dummy_db']);
         if ($restoreDrizzle === 'PMA_TEST_CONSTANT_REMOVE') {
             runkit_constant_remove('PMA_DRIZZLE');
         } else {
             runkit_constant_redefine('PMA_DRIZZLE', $restoreDrizzle);
         }
     }
 }
 /**
  * Test for AuthenticationConfig::authCheck with constant modifications
  *
  * @return void
  */
 public function testAuthCheckWithConstants()
 {
     if (!defined('PMA_CLEAR_COOKIES') && !PMA_HAS_RUNKIT) {
         $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension');
     }
     $remove = false;
     if (!defined('PMA_CLEAR_COOKIES')) {
         define('PMA_CLEAR_COOKIES', true);
         $remove = true;
     }
     $GLOBALS['cfg']['Server']['auth_swekey_config'] = 'testConfigSwekey';
     $GLOBALS['cfg']['Servers'] = array(1);
     $_COOKIE['pmaPass-0'] = 1;
     $_COOKIE['pmaServer-0'] = 1;
     $_COOKIE['pmaUser-0'] = 1;
     $this->assertFalse($this->object->authCheck());
     $this->assertFalse(isset($_COOKIE['pmaPass-0']));
     $this->assertFalse(isset($_COOKIE['pmaServer-0']));
     $this->assertFalse(isset($_COOKIE['pmaUser-0']));
     if ($remove) {
         runkit_constant_remove('PMA_CLEAR_COOKIES');
     }
 }
 /**
  * do debug mode
  */
 public static function do_debug_mode()
 {
     //turn off/on debug mode
     if (hw_option('debug') && (!defined('WP_DEBUG') || !WP_DEBUG)) {
         if (function_exists('runkit_constant_remove') && defined('WP_DEBUG')) {
             runkit_constant_remove("WP_DEBUG");
         }
         if (!defined('WP_DEBUG')) {
             define("WP_DEBUG", true);
         }
         //turn debug
     }
     if (defined('WP_DEBUG') && WP_DEBUG) {
         if (function_exists('runkit_constant_remove') && defined('WP_DEBUG')) {
             runkit_constant_remove("WP_DEBUG");
         }
         if (!defined('WP_DEBUG')) {
             define("WP_DEBUG", false);
         }
     }
 }
Example #14
0
 /**
  * @param string $name
  *
  * @return boolean
  */
 public function removeConstant($name)
 {
     if (!function_exists('runkit_constant_remove')) {
         return false;
     }
     return runkit_constant_remove($name);
 }
Example #15
0
function redefine_mailchimp_capability()
{
    runkit_constant_remove('MCSF_CAP_THRESHOLD');
    define('MCSF_CAP_THRESHOLD', 'mailchimp_options');
}
    public function testSendHeaderLocationWithoutSidWithIis()
    {
        if ($this->runkitExt && $this->apdExt) {

            runkit_constant_redefine('PMA_IS_IIS', true);
            runkit_constant_add('PMA_COMING_FROM_COOKIE_LOGIN', true);

            $testUri = 'http://testurl.com/test.php';
            $separator = PMA_get_arg_separator();

            $header = 'Refresh: 0; ' . $testUri;

            PMA_sendHeaderLocation($testUri);            // sets $GLOBALS['header']

            // cleaning constant
            runkit_constant_remove('PMA_COMING_FROM_COOKIE_LOGIN');

            $this->assertEquals($header, $GLOBALS['header']);

        } else {
            $this->markTestSkipped('Cannot redefine constant/function - missing APD or/and runkit extension');
        }

    }
Example #17
-1
 /**
  * Test for FormDisplay::_setComments
  *
  * @return void
  */
 public function testSetComments()
 {
     if (!PMA_HAS_RUNKIT) {
         $this->markTestSkipped('Cannot redefine constant');
     }
     $method = new \ReflectionMethod('PMA\\libraries\\config\\FormDisplay', '_setComments');
     $method->setAccessible(true);
     // recoding
     $opts = array('values' => array());
     $opts['values']['iconv'] = 'testIconv';
     $opts['values']['recode'] = 'testRecode';
     $expect = $opts;
     $method->invokeArgs($this->object, array('RecodingEngine', &$opts));
     $expect['comment'] = '';
     if (!function_exists('iconv')) {
         $expect['values']['iconv'] .= " (unavailable)";
         $expect['comment'] = '"iconv" requires iconv extension';
     }
     if (!function_exists('recode_string')) {
         $expect['values']['recode'] .= " (unavailable)";
         $expect['comment'] .= ($expect['comment'] ? ", " : '') . '"recode" requires recode extension';
     }
     $expect['comment_warning'] = 1;
     $this->assertEquals($expect, $opts);
     // ZipDump, GZipDump, BZipDump
     $method->invokeArgs($this->object, array('ZipDump', &$opts));
     $comment = '';
     if (!function_exists("zip_open")) {
         $comment = 'Compressed import will not work due to missing function ' . 'zip_open.';
     }
     if (!function_exists("gzcompress")) {
         $comment .= ($comment ? '; ' : '') . 'Compressed export will not work ' . 'due to missing function gzcompress.';
     }
     $this->assertEquals($comment, $opts['comment']);
     $this->assertTrue($opts['comment_warning']);
     $method->invokeArgs($this->object, array('GZipDump', &$opts));
     $comment = '';
     if (!function_exists("gzopen")) {
         $comment = 'Compressed import will not work due to missing function ' . 'gzopen.';
     }
     if (!function_exists("gzencode")) {
         $comment .= ($comment ? '; ' : '') . 'Compressed export will not work ' . 'due to missing function gzencode.';
     }
     $this->assertEquals($comment, $opts['comment']);
     $this->assertTrue($opts['comment_warning']);
     $method->invokeArgs($this->object, array('BZipDump', &$opts));
     $comment = '';
     if (!function_exists("bzopen")) {
         $comment = 'Compressed import will not work due to missing function ' . 'bzopen.';
     }
     if (!function_exists("bzcompress")) {
         $comment .= ($comment ? '; ' : '') . 'Compressed export will not work ' . 'due to missing function bzcompress.';
     }
     $this->assertEquals($comment, $opts['comment']);
     $this->assertTrue($opts['comment_warning']);
     if (defined('PMA_SETUP')) {
         runkit_constant_remove('PMA_SETUP');
     }
     $GLOBALS['cfg']['MaxDbList'] = 10;
     $GLOBALS['cfg']['MaxTableList'] = 10;
     $GLOBALS['cfg']['QueryHistoryMax'] = 10;
     $method->invokeArgs($this->object, array('MaxDbList', &$opts));
     $this->assertEquals("maximum 10", $opts['comment']);
     $method->invokeArgs($this->object, array('MaxTableList', &$opts));
     $this->assertEquals("maximum 10", $opts['comment']);
     $method->invokeArgs($this->object, array('QueryHistoryMax', &$opts));
     $this->assertEquals("maximum 10", $opts['comment']);
 }