Cleaned up longhand arrays, added Profanity tests
This commit is contained in:
parent
5678e75fbd
commit
ff44cd0e17
6 changed files with 100 additions and 73 deletions
|
@ -12,5 +12,3 @@ Validate
|
||||||
|
|
||||||
API/AYAH
|
API/AYAH
|
||||||
API/Gravatar
|
API/Gravatar
|
||||||
API/Tinychat
|
|
||||||
API/Google/Profanity
|
|
||||||
|
|
29
tests/classes/API/Google/ProfanityTest.php
Normal file
29
tests/classes/API/Google/ProfanityTest.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class API_Google_ProfanityTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider providerFormatPhoneNumber
|
||||||
|
*/
|
||||||
|
public function testCheck($a, $b)
|
||||||
|
{
|
||||||
|
$this->assertEquals($b, API_Google_Profanity::check($a));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function providerFormatPhoneNumber()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['alpha', false],
|
||||||
|
['beta', false],
|
||||||
|
['joshtronic', false],
|
||||||
|
['god', false],
|
||||||
|
['fck', false],
|
||||||
|
['fuck', true],
|
||||||
|
['shit', true],
|
||||||
|
['cocksucker', true],
|
||||||
|
['cuntface', false], // Unsure why not...
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -12,14 +12,14 @@ class ConvertTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerArrayToXML()
|
public function providerArrayToXML()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array('foo', false, ''),
|
['foo', false, ''],
|
||||||
array(array('foo', 'bar'), false, '<0>foo</0><1>bar</1>'),
|
[['foo', 'bar'], false, '<0>foo</0><1>bar</1>'],
|
||||||
array(array('foo', 'bar'), true, "<0>foo</0>\n<1>bar</1>\n"),
|
[['foo', 'bar'], true, "<0>foo</0>\n<1>bar</1>\n"],
|
||||||
array(array('foo' => 'bar'), false, '<foo>bar</foo>'),
|
[['foo' => 'bar'], false, '<foo>bar</foo>'],
|
||||||
array(array('children' => array('child' => array('foo', 'bar'))), false, '<children><child>foo</child><child>bar</child></children>'),
|
[['children' => ['child' => ['foo', 'bar']]], false, '<children><child>foo</child><child>bar</child></children>'],
|
||||||
array(array('children' => array('child' => array('foo', 'bar'))), true, "<children>\n\t<child>foo</child>\n\t<child>bar</child>\n</children>\n"),
|
[['children' => ['child' => ['foo', 'bar']]], true, "<children>\n\t<child>foo</child>\n\t<child>bar</child>\n</children>\n"],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@ class DateTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$time = strtotime('-25 years');
|
$time = strtotime('-25 years');
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
array(date('Y-m-d', $time), '25'),
|
[date('Y-m-d', $time), '25'],
|
||||||
array(date('m/d/Y', $time), '25'),
|
[date('m/d/Y', $time), '25'],
|
||||||
array(date('r', $time), '25'),
|
[date('r', $time), '25'],
|
||||||
array('today', '0'),
|
['today', '0'],
|
||||||
array('400 days ago', '1'),
|
['400 days ago', '1'],
|
||||||
array(true, Date::age('1969-12-31')),
|
[true, Date::age('1969-12-31')],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,16 @@ class NumberTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerOrginalIndicatorNoSuper()
|
public function providerOrginalIndicatorNoSuper()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array(1, '1st'),
|
[1, '1st'],
|
||||||
array(2, '2nd'),
|
[2, '2nd'],
|
||||||
array(3, '3rd'),
|
[3, '3rd'],
|
||||||
array(4, '4th'),
|
[4, '4th'],
|
||||||
array(51, '51st'),
|
[51, '51st'],
|
||||||
array(52, '52nd'),
|
[52, '52nd'],
|
||||||
array(53, '53rd'),
|
[53, '53rd'],
|
||||||
array(54, '54th'),
|
[54, '54th'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,16 +34,16 @@ class NumberTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerOrginalIndicatorSuper()
|
public function providerOrginalIndicatorSuper()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array(1, '1<sup>st</sup>'),
|
[1, '1<sup>st</sup>'],
|
||||||
array(2, '2<sup>nd</sup>'),
|
[2, '2<sup>nd</sup>'],
|
||||||
array(3, '3<sup>rd</sup>'),
|
[3, '3<sup>rd</sup>'],
|
||||||
array(4, '4<sup>th</sup>'),
|
[4, '4<sup>th</sup>'],
|
||||||
array(51, '51<sup>st</sup>'),
|
[51, '51<sup>st</sup>'],
|
||||||
array(52, '52<sup>nd</sup>'),
|
[52, '52<sup>nd</sup>'],
|
||||||
array(53, '53<sup>rd</sup>'),
|
[53, '53<sup>rd</sup>'],
|
||||||
array(54, '54<sup>th</sup>'),
|
[54, '54<sup>th</sup>'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,17 +12,17 @@ class StringTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerFormatPhoneNumber()
|
public function providerFormatPhoneNumber()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array('1234567890', '123-456-7890'),
|
['1234567890', '123-456-7890'],
|
||||||
array('123 456 7890', '123-456-7890'),
|
['123 456 7890', '123-456-7890'],
|
||||||
array('123.456.7890', '123-456-7890'),
|
['123.456.7890', '123-456-7890'],
|
||||||
array('123_456_7890', '123-456-7890'),
|
['123_456_7890', '123-456-7890'],
|
||||||
array('1234567890', '123-456-7890'),
|
['1234567890', '123-456-7890'],
|
||||||
array('1234-56-7890', '123-456-7890'),
|
['1234-56-7890', '123-456-7890'],
|
||||||
array('(123) 456-7890', '123-456-7890'),
|
['(123) 456-7890', '123-456-7890'],
|
||||||
array('1234567890 x1000', '123-456-7890x1000'),
|
['1234567890 x1000', '123-456-7890x1000'],
|
||||||
array('(123) 456-7890_x10.00', '123-456-7890x1000'),
|
['(123) 456-7890_x10.00', '123-456-7890x1000'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,10 +35,10 @@ class StringTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerGenerateGravatarHash()
|
public function providerGenerateGravatarHash()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array('foo@bar.com', 'f3ada405ce890b6f8204094deb12d8a8'),
|
['foo@bar.com', 'f3ada405ce890b6f8204094deb12d8a8'],
|
||||||
array('FOO@BAR.COM', 'f3ada405ce890b6f8204094deb12d8a8'),
|
['FOO@BAR.COM', 'f3ada405ce890b6f8204094deb12d8a8'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsEmpty()
|
public function testIsEmpty()
|
||||||
|
@ -79,12 +79,12 @@ class StringTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerTruncate()
|
public function providerTruncate()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array('foo bar', 3, true, '<span title="foo bar">foo…</span>'),
|
['foo bar', 3, true, '<span title="foo bar">foo…</span>'],
|
||||||
array('foo bar', 3, false, 'foo...'),
|
['foo bar', 3, false, 'foo...'],
|
||||||
array('foo bar', 7, true, 'foo bar'),
|
['foo bar', 7, true, 'foo bar'],
|
||||||
array('foo bar', 8, true, 'foo bar'),
|
['foo bar', 8, true, 'foo bar'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,13 +97,13 @@ class StringTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerUpperWords()
|
public function providerUpperWords()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array('foo bar', 'Foo Bar'),
|
['foo bar', 'Foo Bar'],
|
||||||
array('FOO BAR', 'Foo Bar'),
|
['FOO BAR', 'Foo Bar'],
|
||||||
array('fOO bAR', 'Foo Bar'),
|
['fOO bAR', 'Foo Bar'],
|
||||||
array('foo@bar.com', 'foo@bar.com'),
|
['foo@bar.com', 'foo@bar.com'],
|
||||||
array('FOO@BAR.COM', 'FOO@BAR.COM'),
|
['FOO@BAR.COM', 'FOO@BAR.COM'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,13 +116,13 @@ class StringTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function providerGenerateSlug()
|
public function providerGenerateSlug()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
array('TEST STRING', 'test-string'),
|
['TEST STRING', 'test-string'],
|
||||||
array('Test String', 'test-string'),
|
['Test String', 'test-string'],
|
||||||
array('TEST STRING', 'test-string'),
|
['TEST STRING', 'test-string'],
|
||||||
array('#! Test String', 'test-string'),
|
['#! Test String', 'test-string'],
|
||||||
array('-test--string-', 'test-string'),
|
['-test--string-', 'test-string'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPluralize()
|
public function testPluralize()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue