]> git.mxchange.org Git - friendica.git/blob - tests/autoname_test.php
Merge branch 'master' of https://github.com/friendica/friendica
[friendica.git] / tests / autoname_test.php
1 <?php
2 /**
3  * this file contains tests for the autoname function
4  * 
5  * @package test.util
6  */
7
8 /** required, it is the file under test */
9 require_once('include/text.php');
10
11 /**
12  * TestCase for the autoname function
13  * 
14  * @author Alexander Kampmann
15  * @package test.util
16  */
17 class AutonameTest extends PHPUnit_Framework_TestCase {
18         /**\r
19          *autonames should be random, even length\r
20          */\r
21         public function testAutonameEven() {\r
22                 $autoname1=autoname(10);\r
23                 $autoname2=autoname(10);\r
24         \r
25                 $this->assertNotEquals($autoname1, $autoname2);\r
26         }\r
27         \r
28         /**\r
29          *autonames should be random, odd length\r
30          */\r
31         public function testAutonameOdd() {\r
32                 $autoname1=autoname(9);\r
33                 $autoname2=autoname(9);\r
34         \r
35                 $this->assertNotEquals($autoname1, $autoname2);\r
36         }\r
37         \r
38         /**\r
39          * try to fail autonames\r
40          */\r
41         public function testAutonameNoLength() {\r
42                 $autoname1=autoname(0);\r
43                 $this->assertEquals(0, count($autoname1));\r
44         }\r
45         
46         /**
47          * try to fail it with invalid input
48          * 
49          * TODO: What's corect behaviour here? An exception?
50          */\r
51         public function testAutonameNegativeLength() {\r
52                 $autoname1=autoname(-23);\r
53                 $this->assertEquals(0, count($autoname1));\r
54         }\r
55         \r
56         //      public function testAutonameMaxLength() {\r
57         //              $autoname2=autoname(PHP_INT_MAX);\r
58         //              $this->assertEquals(PHP_INT_MAX, count($autoname2));\r
59         //      }\r
60         
61         /**
62          * test with a length, that may be too short
63          */\r
64         public function testAutonameLength1() {\r
65                 $autoname1=autoname(1);\r
66                 $this->assertEquals(1, count($autoname1));
67                 
68                 $autoname2=autoname(1);\r
69                 $this->assertEquals(1, count($autoname2));
70                 
71                 $this->assertFalse($autoname1==$autoname2); \r
72         }
73 }