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
\r
21 public function testAutonameEven() {
\r
22 $autoname1=autoname(10);
\r
23 $autoname2=autoname(10);
\r
25 $this->assertNotEquals($autoname1, $autoname2);
\r
29 *autonames should be random, odd length
\r
31 public function testAutonameOdd() {
\r
32 $autoname1=autoname(9);
\r
33 $autoname2=autoname(9);
\r
35 $this->assertNotEquals($autoname1, $autoname2);
\r
39 * try to fail autonames
\r
41 public function testAutonameNoLength() {
\r
42 $autoname1=autoname(0);
\r
43 $this->assertEquals(0, count($autoname1));
\r
47 * try to fail it with invalid input
49 * TODO: What's corect behaviour here? An exception?
51 public function testAutonameNegativeLength() {
\r
52 $autoname1=autoname(-23);
\r
53 $this->assertEquals(0, count($autoname1));
\r
56 // public function testAutonameMaxLength() {
\r
57 // $autoname2=autoname(PHP_INT_MAX);
\r
58 // $this->assertEquals(PHP_INT_MAX, count($autoname2));
\r
62 * test with a length, that may be too short
64 public function testAutonameLength1() {
\r
65 $autoname1=autoname(1);
\r
66 $this->assertEquals(1, count($autoname1));
68 $autoname2=autoname(1);
\r
69 $this->assertEquals(1, count($autoname2));
71 $this->assertFalse($autoname1==$autoname2);
\r