mirror of
https://github.com/friendica/friendica
synced 2025-04-25 05:50:12 +00:00
Move expand_acl to ACLFormatter::expand()
- including tests
This commit is contained in:
parent
7a9c5d10ee
commit
f65f7f11c3
8 changed files with 224 additions and 160 deletions
|
@ -13,133 +13,6 @@ use PHPUnit\Framework\TestCase;
|
|||
*/
|
||||
class TextTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* test expand_acl, perfect input
|
||||
*/
|
||||
public function testExpandAclNormal()
|
||||
{
|
||||
$text='<1><2><3><' . Group::FOLLOWERS . '><' . Group::MUTUALS . '>';
|
||||
$this->assertEquals(array('1', '2', '3', Group::FOLLOWERS, Group::MUTUALS), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test with a big number
|
||||
*/
|
||||
public function testExpandAclBigNumber()
|
||||
{
|
||||
$text='<1><' . PHP_INT_MAX . '><15>';
|
||||
$this->assertEquals(array('1', (string)PHP_INT_MAX, '15'), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test with a string in it.
|
||||
*
|
||||
* @todo is this valid input? Otherwise: should there be an exception?
|
||||
*/
|
||||
public function testExpandAclString()
|
||||
{
|
||||
$text="<1><279012><tt>";
|
||||
$this->assertEquals(array('1', '279012'), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test with a ' ' in it.
|
||||
*
|
||||
* @todo is this valid input? Otherwise: should there be an exception?
|
||||
*/
|
||||
public function testExpandAclSpace()
|
||||
{
|
||||
$text="<1><279 012><32>";
|
||||
$this->assertEquals(array('1', '32'), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test empty input
|
||||
*/
|
||||
public function testExpandAclEmpty()
|
||||
{
|
||||
$text="";
|
||||
$this->assertEquals(array(), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test invalid input, no < at all
|
||||
*
|
||||
* @todo should there be an exception?
|
||||
*/
|
||||
public function testExpandAclNoBrackets()
|
||||
{
|
||||
$text="According to documentation, that's invalid. "; //should be invalid
|
||||
$this->assertEquals(array(), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test invalid input, just open <
|
||||
*
|
||||
* @todo should there be an exception?
|
||||
*/
|
||||
public function testExpandAclJustOneBracket1()
|
||||
{
|
||||
$text="<Another invalid string"; //should be invalid
|
||||
$this->assertEquals(array(), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test invalid input, just close >
|
||||
*
|
||||
* @todo should there be an exception?
|
||||
*/
|
||||
public function testExpandAclJustOneBracket2()
|
||||
{
|
||||
$text="Another invalid> string"; //should be invalid
|
||||
$this->assertEquals(array(), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test invalid input, just close >
|
||||
*
|
||||
* @todo should there be an exception?
|
||||
*/
|
||||
public function testExpandAclCloseOnly()
|
||||
{
|
||||
$text="Another> invalid> string>"; //should be invalid
|
||||
$this->assertEquals(array(), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test invalid input, just open <
|
||||
*
|
||||
* @todo should there be an exception?
|
||||
*/
|
||||
public function testExpandAclOpenOnly()
|
||||
{
|
||||
$text="<Another< invalid string<"; //should be invalid
|
||||
$this->assertEquals(array(), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test invalid input, open and close do not match
|
||||
*
|
||||
* @todo should there be an exception?
|
||||
*/
|
||||
public function testExpandAclNoMatching1()
|
||||
{
|
||||
$text="<Another<> invalid <string>"; //should be invalid
|
||||
$this->assertEquals(array(), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test invalid input, empty <>
|
||||
*
|
||||
* @todo should there be an exception? Or array(1, 3)
|
||||
* (This should be array(1,3) - mike)
|
||||
*/
|
||||
public function testExpandAclEmptyMatch()
|
||||
{
|
||||
$text="<1><><3>";
|
||||
$this->assertEquals(array('1', '3'), expand_acl($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* test hex2bin and reverse
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue