3 * this file contains tests for the autoname function
8 /** required, it is the file under test */
9 require_once('include/text.php');
12 * TestCase for the autoname function
14 * @author Alexander Kampmann
17 class AutonameTest extends PHPUnit_Framework_TestCase {
19 *autonames should be random, even length
21 public function testAutonameEven() {
22 $autoname1=autoname(10);
23 $autoname2=autoname(10);
25 $this->assertNotEquals($autoname1, $autoname2);
29 *autonames should be random, odd length
31 public function testAutonameOdd() {
32 $autoname1=autoname(9);
33 $autoname2=autoname(9);
35 $this->assertNotEquals($autoname1, $autoname2);
39 * try to fail autonames
41 public function testAutonameNoLength() {
42 $autoname1=autoname(0);
43 $this->assertEquals(0, strlen($autoname1));
47 * try to fail it with invalid input
49 * TODO: What's corect behaviour here? An exception?
51 public function testAutonameNegativeLength() {
52 $autoname1=autoname(-23);
53 $this->assertEquals(0, strlen($autoname1));
56 // public function testAutonameMaxLength() {
57 // $autoname2=autoname(PHP_INT_MAX);
58 // $this->assertEquals(PHP_INT_MAX, count($autoname2));
62 * test with a length, that may be too short
64 public function testAutonameLength1() {
65 $autoname1=autoname(1);
66 $this->assertEquals(1, count($autoname1));
68 $autoname2=autoname(1);
69 $this->assertEquals(1, count($autoname2));
71 // The following test is problematic, with only 26 possibilities
72 // generating the same thing twice happens often aka
74 // $this->assertFalse($autoname1==$autoname2);