Enhance PHPUnit tests

This commit is contained in:
eldy 2011-10-05 13:56:32 +02:00
parent 822d4508eb
commit f4a3e6a1a7
2 changed files with 42 additions and 8 deletions

View File

@ -1075,7 +1075,8 @@ abstract class CommonObject
/** /**
* Update public note of element * Update public note of element
* @param note_public New value for note *
* @param string $note_public New value for note
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update_note_public($note_public) function update_note_public($note_public)

View File

@ -167,9 +167,42 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$db=$this->savdb; $db=$this->savdb;
$localobject->note='New note after update'; $localobject->note='New note after update';
//$localobject->note_public='New note public after update';
$localobject->name='New name';
$localobject->address='New address';
$localobject->zip='New zip';
$localobject->town='New town';
$localobject->status=0;
$localobject->tel='New tel';
$localobject->fax='New fax';
$localobject->email='New email';
$localobject->url='New url';
$result=$localobject->update($localobject->id,$user); $result=$localobject->update($localobject->id,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
$result=$localobject->update_note($localobject->note);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
//$result=$localobject->update_note_public($localobject->note_public);
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
//$this->assertLessThan($result, 0);
$newobject=new Societe($this->savdb);
$result=$newobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$this->assertEquals($localobject->note, $newobject->note);
//$this->assertEquals($localobject->note_public, $newobject->note_public);
$this->assertEquals($localobject->name, $newobject->name);
$this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->status, $newobject->status);
$this->assertEquals($localobject->tel, $newobject->tel);
$this->assertEquals($localobject->fax, $newobject->fax);
$this->assertEquals($localobject->email, $newobject->email);
$this->assertEquals($localobject->url, $newobject->url);
return $localobject; return $localobject;
} }
@ -208,7 +241,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$result=$localobject->getFullAddress(); $result=$localobject->getFullAddress();
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertContains('MyTown', $result); $this->assertContains("New address\nNew zip New town", $result);
$result=$localobject->isInEEC(); $result=$localobject->isInEEC();
print __METHOD__." id=".$localobject->id." pays_code=".$this->pays_code." result=".$result."\n"; print __METHOD__." id=".$localobject->id." pays_code=".$this->pays_code." result=".$result."\n";