Rev 1285 | Blame | Last modification | View Log | RSS feed
<?php
require dirname(__FILE__).'/../../bibliotheque/Surligneur.php';
class SurligneurTest extends PHPUnit_Framework_TestCase {
/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage Surligneur::surlignerMots() n'accepte que les tableaux de mots en argument
*/
public function testerSurlignerMotsAvecChaineRetourneInvalidArgumentException() {
$surligneur = new Surligneur();
$surligneur->surlignerMots('test');
}
/**
* @expectedException LengthException
* @expectedExceptionMessage Surligneur::surlignerMots() n'accepte que des tableaux contenant au moins un mot
*/
public function testerSurlignerMotsAvecTableauVideRetourneLengthException() {
$surligneur = new Surligneur();
$surligneur->surlignerMots(array());
}
public function testerSurlignerMotsRetournePremiereOccurenceMotSurlignee() {
$surligneur = new Surligneur();
$surligneur->setTexte('Viola alba subsp. alba');
$txtSurligne = $surligneur->surlignerMots(array('viola', 'al'));
$txtSurligneAttendu = '<span class="surlignage">Viola</span> <span class="surlignage">al</span>ba subsp. alba';
$this->assertEquals($txtSurligneAttendu, $txtSurligne);
}
public function testerSurlignerMotsRetourneDeuxPremieresOccurencesMotSurlignees() {
$surligneur = new Surligneur();
$surligneur->setNbreMaxSurlignageParMot(2);
$surligneur->setTexte('Viola alba subsp. alba');
$txtSurligne = $surligneur->surlignerMots(array('viola', 'al'));
$txtSurligneAttendu = '<span class="surlignage">Viola</span> <span class="surlignage">al</span>ba subsp. <span class="surlignage">al</span>ba';
$this->assertEquals($txtSurligneAttendu, $txtSurligne);
}
public function testerSurlignerMotsParConstructeurRetourneDeuxPremieresOccurencesMotSurlignees() {
$surligneur = new Surligneur('Viola alba subsp. alba', 2);
$txtSurligne = $surligneur->surlignerMots(array('viola', 'al'));
$txtSurligneAttendu = '<span class="surlignage">Viola</span> <span class="surlignage">al</span>ba subsp. <span class="surlignage">al</span>ba';
$this->assertEquals($txtSurligneAttendu, $txtSurligne);
}
}
?>