Commit 7ebb9fa6 by Scott

Tests: fix visibility, move to correct classes

parent bfa0663d
<?php
class BaseTest extends PHPUnit_Framework_TestCase
{
public function test__qa_js() {
$test = qa_js('test');
$this->assertEquals($test, "'test'");
$test = qa_js('test', true);
$this->assertEquals($test, "'test'");
$test = qa_js(123);
$this->assertEquals($test, 123);
$test = qa_js(123, true);
$this->assertEquals($test, "'123'");
$test = qa_js(true);
$this->assertEquals($test, 'true');
$test = qa_js(true, true);
$this->assertEquals($test, "'true'");
}
}
...@@ -7,7 +7,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -7,7 +7,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
private $strAccents = 'Țĥé qũīçĶ ßřǭŴƞ Ƒöŧ ǰÙƢƥş ØƲĘŕ ƮĦȨ ĿÆƶȳ Ƌơǥ'; private $strAccents = 'Țĥé qũīçĶ ßřǭŴƞ Ƒöŧ ǰÙƢƥş ØƲĘŕ ƮĦȨ ĿÆƶȳ Ƌơǥ';
private $blockWordString = 't*d o*n b*t style'; private $blockWordString = 't*d o*n b*t style';
function test__qa_string_to_words() public function test__qa_string_to_words()
{ {
$test1 = qa_string_to_words($this->strBasic); $test1 = qa_string_to_words($this->strBasic);
$expected1 = array('so', 'i', 'tied', 'an', 'onion', 'to', 'my', 'belt', 'which', 'was', 'the', 'style', 'at', 'the', 'time'); $expected1 = array('so', 'i', 'tied', 'an', 'onion', 'to', 'my', 'belt', 'which', 'was', 'the', 'style', 'at', 'the', 'time');
...@@ -19,7 +19,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -19,7 +19,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected2, $test2); $this->assertEquals($expected2, $test2);
} }
function test__qa_string_remove_accents() public function test__qa_string_remove_accents()
{ {
$test = qa_string_remove_accents($this->strAccents); $test = qa_string_remove_accents($this->strAccents);
$expected = 'The quicK ssroWn Fot jUOIps OVEr THE LAEzy Dog'; $expected = 'The quicK ssroWn Fot jUOIps OVEr THE LAEzy Dog';
...@@ -27,7 +27,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -27,7 +27,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test); $this->assertEquals($expected, $test);
} }
function test__qa_tags_to_tagstring() public function test__qa_tags_to_tagstring()
{ {
$test = qa_tags_to_tagstring( array('Hello', 'World') ); $test = qa_tags_to_tagstring( array('Hello', 'World') );
$expected = 'Hello,World'; $expected = 'Hello,World';
...@@ -35,7 +35,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -35,7 +35,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test); $this->assertEquals($expected, $test);
} }
function test__qa_tagstring_to_tags() public function test__qa_tagstring_to_tags()
{ {
$test = qa_tagstring_to_tags('hello,world'); $test = qa_tagstring_to_tags('hello,world');
$expected = array('hello', 'world'); $expected = array('hello', 'world');
...@@ -43,7 +43,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -43,7 +43,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test); $this->assertEquals($expected, $test);
} }
function test__qa_shorten_string_line() public function test__qa_shorten_string_line()
{ {
// qa_shorten_string_line ($string, $length) // qa_shorten_string_line ($string, $length)
...@@ -54,7 +54,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -54,7 +54,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertNotFalse(strpos($test, '...')); $this->assertNotFalse(strpos($test, '...'));
} }
function test__qa_block_words_explode() public function test__qa_block_words_explode()
{ {
$test = qa_block_words_explode($this->blockWordString); $test = qa_block_words_explode($this->blockWordString);
$expected = array('t*d', 'o*n', 'b*t', 'style'); $expected = array('t*d', 'o*n', 'b*t', 'style');
...@@ -62,7 +62,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -62,7 +62,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test); $this->assertEquals($expected, $test);
} }
function test__qa_block_words_to_preg() public function test__qa_block_words_to_preg()
{ {
$test = qa_block_words_to_preg($this->blockWordString); $test = qa_block_words_to_preg($this->blockWordString);
$expected = '(?<= )t[^ ]*d(?= )|(?<= )o[^ ]*n(?= )|(?<= )b[^ ]*t(?= )|(?<= )style(?= )'; $expected = '(?<= )t[^ ]*d(?= )|(?<= )o[^ ]*n(?= )|(?<= )b[^ ]*t(?= )|(?<= )style(?= )';
...@@ -70,7 +70,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -70,7 +70,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test); $this->assertEquals($expected, $test);
} }
function test__qa_block_words_match_all() public function test__qa_block_words_match_all()
{ {
$test1 = qa_block_words_match_all('onion belt', ''); $test1 = qa_block_words_match_all('onion belt', '');
...@@ -87,7 +87,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -87,7 +87,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test2); $this->assertEquals($expected, $test2);
} }
function test__qa_block_words_replace() public function test__qa_block_words_replace()
{ {
$wordpreg = qa_block_words_to_preg($this->blockWordString); $wordpreg = qa_block_words_to_preg($this->blockWordString);
$test = qa_block_words_replace('tired of my ocean boat style', $wordpreg); $test = qa_block_words_replace('tired of my ocean boat style', $wordpreg);
...@@ -96,7 +96,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -96,7 +96,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $test); $this->assertEquals($expected, $test);
} }
function test__qa_random_alphanum() public function test__qa_random_alphanum()
{ {
$len = 50; $len = 50;
$test = qa_random_alphanum($len); $test = qa_random_alphanum($len);
...@@ -104,7 +104,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -104,7 +104,7 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertEquals(strlen($test), $len); $this->assertEquals(strlen($test), $len);
} }
function test__qa_email_validate() public function test__qa_email_validate()
{ {
$goodEmails = array( $goodEmails = array(
'hello@example.com', 'hello@example.com',
...@@ -125,28 +125,28 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -125,28 +125,28 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertFalse( qa_email_validate($email) ); $this->assertFalse( qa_email_validate($email) );
} }
function test__qa_strlen() public function test__qa_strlen()
{ {
$test = qa_strlen($this->strAccents); $test = qa_strlen($this->strAccents);
$this->assertEquals($test, 43); $this->assertEquals($test, 43);
} }
function test__qa_strtolower() public function test__qa_strtolower()
{ {
$test = qa_strtolower('hElLo WoRld'); $test = qa_strtolower('hElLo WoRld');
$this->assertEquals($test, 'hello world'); $this->assertEquals($test, 'hello world');
} }
function test__qa_substr() public function test__qa_substr()
{ {
$test = qa_substr($this->strBasic, 5, 24); $test = qa_substr($this->strBasic, 5, 24);
$this->assertEquals($test, 'tied an onion to my belt'); $this->assertEquals($test, 'tied an onion to my belt');
} }
function test__qa_string_matches_one() public function test__qa_string_matches_one()
{ {
$matches = array( 'dyed', 'shallot', 'belt', 'fashion' ); $matches = array( 'dyed', 'shallot', 'belt', 'fashion' );
$nonMatches = array( 'dyed', 'shallot', 'buckle', 'fashion' ); $nonMatches = array( 'dyed', 'shallot', 'buckle', 'fashion' );
...@@ -155,23 +155,4 @@ class UtilStringTest extends PHPUnit_Framework_TestCase ...@@ -155,23 +155,4 @@ class UtilStringTest extends PHPUnit_Framework_TestCase
$this->assertFalse( qa_string_matches_one($this->strBasic, $nonMatches) ); $this->assertFalse( qa_string_matches_one($this->strBasic, $nonMatches) );
} }
function test__qa_js() {
$test = qa_js('test');
$this->assertEquals($test, "'test'");
$test = qa_js('test', true);
$this->assertEquals($test, "'test'");
$test = qa_js(123);
$this->assertEquals($test, 123);
$test = qa_js(123, true);
$this->assertEquals($test, "'123'");
$test = qa_js(true);
$this->assertEquals($test, 'true');
$test = qa_js(true, true);
$this->assertEquals($test, "'true'");
}
} }
...@@ -8,10 +8,13 @@ ...@@ -8,10 +8,13 @@
<exclude-pattern>qa-plugin/facebook-login/facebook.php</exclude-pattern> <exclude-pattern>qa-plugin/facebook-login/facebook.php</exclude-pattern>
<exclude-pattern>qa-plugin/facebook-login/base_facebook.php</exclude-pattern> <exclude-pattern>qa-plugin/facebook-login/base_facebook.php</exclude-pattern>
<rule ref="PSR1"/> <rule ref="PSR1">
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
</rule>
<rule ref="PSR2"> <rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/> <exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
<exclude name="Generic.Files.LineLength.TooLong"/>
<exclude name="Squiz.ControlStructures.ControlSignature"/> <exclude name="Squiz.ControlStructures.ControlSignature"/>
<exclude name="Generic.ControlStructures.InlineControlStructure"/> <exclude name="Generic.ControlStructures.InlineControlStructure"/>
......
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