Allows for injecting endpoints to simulate poor responses while still testing the responses from the actual endpoint.
52 lines
922 B
PHP
52 lines
922 B
PHP
<?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...
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @expectedException Exception
|
|
* @expectedExceptionMessage Invalid response from API.
|
|
*/
|
|
public function testNullResponse()
|
|
{
|
|
$file = SITE_PATH . 'null-';
|
|
|
|
file_put_contents($file . 'test', null);
|
|
|
|
API_Google_Profanity::check('test', $file);
|
|
}
|
|
|
|
public function testMissingResponse()
|
|
{
|
|
|
|
}
|
|
|
|
public function testInvalidResponse()
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
?>
|