/**
  * Test for PMA_getJsValue
  *
  * @param string $key      Key
  * @param string $value    Value
  * @param string $expected Expected output
  *
  * @dataProvider variables
  *
  * @return void
  */
 public function testFormat($key, $value, $expected)
 {
     $this->assertEquals($expected, PMA_getJsValue($key, $value));
     $this->assertEquals('foo = 100', PMA_getJsValue('foo', '100', false));
     $array = array('1', '2', '3');
     $this->assertEquals("foo = [\"1\",\"2\",\"3\",];\n", PMA_getJsValue('foo', $array));
 }
Example #2
0
/**
 * Adds JS code snippet for variable assignment
 * to be displayed by the PMA_Response class.
 *
 * @param string $key    Name of value to set
 * @param mixed  $value  Value to set, can be either string or array of strings
 * @param bool   $escape Whether to escape value or keep it as it is
 *                       (for inclusion of js code)
 *
 * @return void
 */
function PMA_addJSVar($key, $value, $escape = true)
{
    PMA_addJSCode(PMA_getJsValue($key, $value, $escape));
}
/**
 * Prints an javascript assignment with proper escaping of a value
 * and support for assigning array of strings.
 *
 * @param string $key   Name of value to set
 * @param mixed  $value Value to set, can be either string or array of strings
 *
 * @return void
 */
function PMA_printJsValue($key, $value)
{
    echo PMA_getJsValue($key, $value);
}
Example #4
0
 /**
  * @dataProvider variables
  */
 public function testFormat($key, $value, $expected)
 {
     $this->assertEquals($expected, PMA_getJsValue($key, $value));
 }