Changeset 32863 for trunk/tests/phpunit/tests/formatting/WPTexturize.php
- Timestamp:
- 06/19/2015 08:05:52 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/WPTexturize.php
r32789 r32863 91 91 //$this->assertEquals('Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize('Here is "a test <a href="http://example.com">with a link</a>".')); 92 92 //$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”and a work stuck to the end.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.')); 93 //$this->assertEquals('A test with a finishing number, “like 23”.', wptexturize('A test with a finishing number, "like 23".'));94 //$this->assertEquals('A test with a number, “like 62”, is nice to have.', wptexturize('A test with a number, "like 62", is nice to have.'));93 $this->assertEquals('A test with a finishing number, “like 23”.', wptexturize('A test with a finishing number, "like 23".')); 94 $this->assertEquals('A test with a number, “like 62”, is nice to have.', wptexturize('A test with a number, "like 62", is nice to have.')); 95 95 } 96 96 … … 122 122 $this->assertEquals('‘Class of ’99’s’', wptexturize("'Class of '99's'")); 123 123 $this->assertEquals('‘Class of ’99’s’', wptexturize("'Class of '99’s'")); 124 //$this->assertEquals('“Class of 99”', wptexturize("\"Class of 99\""));124 $this->assertEquals('“Class of 99”', wptexturize("\"Class of 99\"")); 125 125 $this->assertEquals('“Class of ’99”', wptexturize("\"Class of '99\"")); 126 126 $this->assertEquals('{“Class of ’99”}', wptexturize("{\"Class of '99\"}")); … … 1901 1901 ); 1902 1902 } 1903 1904 /** 1905 * Ensure primes logic is not too greedy at the end of a quotation. 1906 * 1907 * @ticket 29256 1908 * @dataProvider data_primes_vs_quotes 1909 */ 1910 function test_primes_vs_quotes( $input, $output ) { 1911 return $this->assertEquals( $output, wptexturize( $input ) ); 1912 } 1913 1914 function data_primes_vs_quotes() { 1915 return array( 1916 array( 1917 "George's porch is 99' long.", 1918 "George’s porch is 99′ long.", 1919 ), 1920 array( 1921 'The best year "was that time in 2012" when everyone partied, he said.', 1922 'The best year “was that time in 2012” when everyone partied, he said.', 1923 ), 1924 array( 1925 "I need 4 x 20' = 80' of trim.", // Works only with a space before the = char. 1926 "I need 4 x 20′ = 80′ of trim.", 1927 ), 1928 array( 1929 '"Lorem ipsum dolor sit amet 1234"', 1930 '“Lorem ipsum dolor sit amet 1234”', 1931 ), 1932 array( 1933 "'Etiam eu egestas dui 1234'", 1934 "‘Etiam eu egestas dui 1234’", 1935 ), 1936 array( 1937 'according to our source, "33% of all students scored less than 50" on the test.', 1938 'according to our source, “33% of all students scored less than 50” on the test.', 1939 ), 1940 array( 1941 "The doctor said, 'An average height is between 5' and 6' in study group 7'. He then produced a 6' chart of averages. A man of 7', incredibly, is very possible.", 1942 "The doctor said, ‘An average height is between 5′ and 6′ in study group 7’. He then produced a 6′ chart of averages. A man of 7′, incredibly, is very possible.", 1943 ), 1944 array( 1945 'Pirates have voted on "The Expendables 3" with their clicks -- and it turns out the Sylvester Stallone-starrer hasn\'t been astoundingly popular among digital thieves, relatively speaking. 1946 1947 As of Sunday, 5.12 million people worldwide had pirated "Expendables 3" since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. 1948 1949 That likely contributed to the action movie\'s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after "Captain America: The Winter Soldier" (7.31 million), "Divergent" (6.29 million) and "The Amazing Spider-Man 2" (5.88 million). Moreover, that\'s despite "Expendables 3" becoming available more than three weeks prior to the film\'s U.S. theatrical debut. 1950 1951 String with a number followed by a single quote \'Expendables 3\' vestibulum in arcu mi.', 1952 1953 'Pirates have voted on “The Expendables 3” with their clicks — and it turns out the Sylvester Stallone-starrer hasn’t been astoundingly popular among digital thieves, relatively speaking. 1954 1955 As of Sunday, 5.12 million people worldwide had pirated “Expendables 3” since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. 1956 1957 That likely contributed to the action movie’s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after “Captain America: The Winter Soldier” (7.31 million), “Divergent” (6.29 million) and “The Amazing Spider-Man 2” (5.88 million). Moreover, that’s despite “Expendables 3” becoming available more than three weeks prior to the film’s U.S. theatrical debut. 1958 1959 String with a number followed by a single quote ‘Expendables 3’ vestibulum in arcu mi.', 1960 ), 1961 ); 1962 } 1963 1964 /** 1965 * Make sure translation actually works. 1966 * 1967 * Also make sure opening and closing quotes are allowed to be identical. 1968 * 1969 * @ticket 29256 1970 * @dataProvider data_primes_quotes_translation 1971 */ 1972 function test_primes_quotes_translation( $input, $output ) { 1973 add_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 ); 1974 1975 $result = wptexturize( $input, true ); 1976 1977 remove_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 ); 1978 wptexturize( 'reset', true ); 1979 1980 return $this->assertEquals( $output, $result ); 1981 } 1982 1983 function filter_translate2( $translations, $text, $context, $domain ) { 1984 switch ($text) { 1985 case '–' : return '!endash!'; 1986 case '—' : return '!emdash!'; 1987 case '‘' : return '!q1!'; 1988 case '’' : 1989 if ( 'apostrophe' == $context ) { 1990 return '!apos!'; 1991 } else { 1992 return '!q1!'; 1993 } 1994 case '“' : return '!q2!'; 1995 case '”' : return '!q2!'; 1996 case '′' : return '!prime1!'; 1997 case '″' : return '!prime2!'; 1998 default : return $translations; 1999 } 2000 } 2001 2002 function data_primes_quotes_translation() { 2003 return array( 2004 array( 2005 "George's porch is 99' long.", 2006 "George!apos!s porch is 99!prime1! long.", 2007 ), 2008 array( 2009 'The best year "was that time in 2012" when everyone partied, he said.', 2010 'The best year !q2!was that time in 2012!q2! when everyone partied, he said.', 2011 ), 2012 array( 2013 "I need 4 x 20' = 80' of trim.", // Works only with a space before the = char. 2014 "I need 4 x 20!prime1! = 80!prime1! of trim.", 2015 ), 2016 array( 2017 '"Lorem ipsum dolor sit amet 1234"', 2018 '!q2!Lorem ipsum dolor sit amet 1234!q2!', 2019 ), 2020 array( 2021 "'Etiam eu egestas dui 1234'", 2022 "!q1!Etiam eu egestas dui 1234!q1!", 2023 ), 2024 array( 2025 'according to our source, "33% of all students scored less than 50" on the test.', 2026 'according to our source, !q2!33% of all students scored less than 50!q2! on the test.', 2027 ), 2028 array( 2029 "The doctor said, 'An average height is between 5' and 6' in study group 7'. He then produced a 6' chart of averages. A man of 7', incredibly, is very possible.", 2030 "The doctor said, !q1!An average height is between 5!prime1! and 6!prime1! in study group 7!q1!. He then produced a 6!prime1! chart of averages. A man of 7!prime1!, incredibly, is very possible.", 2031 ), 2032 array( 2033 'Pirates have voted on "The Expendables 3" with their clicks -- and it turns out the Sylvester Stallone-starrer hasn\'t been astoundingly popular among digital thieves, relatively speaking. 2034 2035 As of Sunday, 5.12 million people worldwide had pirated "Expendables 3" since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. 2036 2037 That likely contributed to the action movie\'s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after "Captain America: The Winter Soldier" (7.31 million), "Divergent" (6.29 million) and "The Amazing Spider-Man 2" (5.88 million). Moreover, that\'s despite "Expendables 3" becoming available more than three weeks prior to the film\'s U.S. theatrical debut. 2038 2039 String with a number followed by a single quote \'Expendables 3\' vestibulum in arcu mi.', 2040 2041 'Pirates have voted on !q2!The Expendables 3!q2! with their clicks !emdash! and it turns out the Sylvester Stallone-starrer hasn!apos!t been astoundingly popular among digital thieves, relatively speaking. 2042 2043 As of Sunday, 5.12 million people worldwide had pirated !q2!Expendables 3!q2! since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. 2044 2045 That likely contributed to the action movie!apos!s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after !q2!Captain America: The Winter Soldier!q2! (7.31 million), !q2!Divergent!q2! (6.29 million) and !q2!The Amazing Spider-Man 2!q2! (5.88 million). Moreover, that!apos!s despite !q2!Expendables 3!q2! becoming available more than three weeks prior to the film!apos!s U.S. theatrical debut. 2046 2047 String with a number followed by a single quote !q1!Expendables 3!q1! vestibulum in arcu mi.', 2048 ), 2049 ); 2050 } 1903 2051 }
Note: See TracChangeset
for help on using the changeset viewer.