Commit f92ad527 by Scott

Tests: qa_slugify

parent 132973ea
......@@ -30,23 +30,27 @@ class BaseTest extends PHPUnit_Framework_TestCase
public function test__qa_q_request()
{
// set options/lang cache to bypass database
global $qa_options_cache;
// set options cache to bypass database
global $qa_options_cache, $qa_blockwordspreg_set;
$title1 = 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?';
$title2 = 'Țĥé qũīçĶ ßřǭŴƞ Ƒöŧ ǰÙƢƥş ØƯĘŕ ƬĦȨ ĿÆƶȳ Ƌơǥ';
$qa_options_cache['block_bad_words'] = '';
$qa_blockwordspreg_set = false;
$qa_options_cache['q_urls_title_length'] = 50;
$qa_options_cache['q_urls_remove_accents'] = false;
$expected1 = '1234/much-wood-would-woodchuck-chuck-woodchuck-could-chuck-wood';
$expected2 = '5678/țĥé-qũīçķ-ßřǭŵƞ-ƒöŧ-ǰùƣƥş-øưęŕ-ƭħȩ-ŀæƶȳ-ƌơǥ';
$this->assertSame($expected1, qa_q_request(1234, $title1));
$this->assertSame($expected2, qa_q_request(5678, $title2));
$qa_options_cache['block_bad_words'] = 'chuck';
$qa_blockwordspreg_set = false;
$qa_options_cache['q_urls_remove_accents'] = true;
$expected2 = '5678/how-much-wood-would-a-woodchuck-if-a-woodchuck-could-wood';
$expected3 = '9000/the-quick-ssrown-fot-juoips-ouer-the-laezy-dog';
$this->assertSame($expected2, qa_q_request(5678, $title1));
$this->assertSame($expected3, qa_q_request(9000, $title2));
}
}
......@@ -27,6 +27,23 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test);
}
public function test__qa_slugify()
{
$title1 = 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?';
$title2 = 'Țĥé qũīçĶ ßřǭŴƞ Ƒöŧ ǰÙƢƥş ØƯĘŕ ƬĦȨ ĿÆƶȳ Ƌơǥ';
$expected1 = 'how-much-wood-would-a-woodchuck-chuck-if-a-woodchuck-could-chuck-wood';
$expected2 = 'much-wood-would-woodchuck-chuck-woodchuck-could-chuck-wood';
$expected3 = 'țĥé-qũīçķ-ßřǭŵƞ-ƒöŧ-ǰùƣƥş-øưęŕ-ƭħȩ-ŀæƶȳ-ƌơǥ';
$expected4 = 'the-quick-ssrown-fot-juoips-ouer-the-laezy-dog';
$this->assertSame($expected1, qa_slugify($title1));
$this->assertSame($expected2, qa_slugify($title1, true, 50));
$this->assertSame($expected3, qa_slugify($title2, false));
$this->assertSame($expected4, qa_slugify($title2, true));
}
public function test__qa_tags_to_tagstring()
{
$test = qa_tags_to_tagstring( array('Hello', 'World') );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment