addIdentifierQuotes( $in ); $this->assertEquals($expected, $quoted); } /** * Feeds testAddIdentifierQuotes * * Named per bug 20281 convention. */ function provideDiapers() { return array( // Format: expected, input array( '``', '' ), // Yeah I really hate loosely typed PHP idiocies nowadays array( '``', null ), // Dear codereviewer, guess what addIdentifierQuotes() // will return with thoses: array( '``', false ), array( '`1`', true ), // We never know what could happen array( '`0`', 0 ), array( '`1`', 1 ), // Whatchout! Should probably use something more meaningful array( "`'`", "'" ), # single quote array( '`"`', '"' ), # double quote array( '````', '`' ), # backtick array( '`’`', '’' ), # apostrophe (look at your encyclopedia) // sneaky NUL bytes are lurking everywhere array( '``', "\0" ), array( '`xyzzy`', "\0x\0y\0z\0z\0y\0" ), // unicode chars array( self::createUnicodeString( '`\u0001a\uFFFFb`' ), self::createUnicodeString( '\u0001a\uFFFFb' ) ), array( self::createUnicodeString( '`\u0001\uFFFF`' ), self::createUnicodeString( '\u0001\u0000\uFFFF\u0000' ) ), array( '`☃`', '☃' ), array( '`メインページ`', 'メインページ' ), array( '`Басты_бет`', 'Басты_бет' ), // Real world: array( '`Alix`', 'Alix' ), # while( ! $recovered ) { sleep(); } array( '`Backtick: ```', 'Backtick: `' ), array( '`This is a test`', 'This is a test' ), ); } private static function createUnicodeString($str) { return json_decode( '"' . $str . '"' ); } }