Wikini

CasDeTestDeWikiNi

PagePrincipale :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes ec2-34-228-7-237.compute-1.amazonaws.com
Nous proposons de lister ici les pages servant à la recette de WikiNi, sous forme de cas de test.
Idéalement, tous ces tests sont répétés à chaque modification majeure de WikiNi et avant chaque changement de version.

Cas de test pour les ReglesDeFormatage


Cas de test pour la gestion des droits




Cas de test pour les handlers

[...]

Cas de test pour les actions

[...]


Automatisation de la recette de Wikini


Il faudrait pouvoir utiliser des outils comme PhpUnit, utilisé dans les projets appliquant la méthode de conduite de projet XP.

En exemple, voici une mise en oeuvre de phpunit pour un test de formatage url de Wikini.

Trois fichiers à inclure à la racine du wikini à tester : wikini.php, testcase.php et wikinitest.php.
<?php
// wikini.php à inclure à la racine du wikini à tester

Class Wikini {
    
    function 
Wikini() {
        global 
$wiki;
        
$_SERVER['PHP_SELF']="wakka.php";
        
$_REQUEST["wiki"]='PeutImporteLeNomDeCettePage';
        
ob_start();
        include_once(
'wakka.php');
        
ob_end_clean();
    }
    
    function 
Format($str) {
        global 
$wiki;
        
$text=$str;
        
ob_start();
        include(
'formatters/wakka.php');
        
$output ob_get_contents();
        
ob_end_clean();
        return 
$output;
    }

}

?>

?>


<?php
// testcase.php  à inclure à la racine du wikini à tester

require_once 'wikini.php';
require_once 
'PHPUnit.php';

class 
WikiniTest extends PHPUnit_TestCase
{
    
// contains the object handle of the string class
    
var $wikini;

    
// constructor of the test suite
    
function WikiniTest($name) {
       
$this->PHPUnit_TestCase($name);
       
$this->wikini = new Wikini();
    }

    
// called before the test functions will be executed
    // this function is defined in PHPUnit_TestCase and overwritten
    // here
    
function setUp() {
        
$this->wikini = new Wikini();
    }

    
// called after the test functions are executed
    // this function is defined in PHPUnit_TestCase and overwritten
    // here
    
function tearDown() {
        
// delete your instance
        
unset($this->wikini);
    }

    function 
test_url() {
        
$result $this->wikini->Format('http://example.org');
        
$expected '<a href="http://example.org">http://example.org</a>';
        
$this->assertTrue($result == $expected,'http://example.org');
        
        
$result $this->wikini->Format('http://example.org/');
        
$expected '<a href="http://example.org/">http://example.org/</a>';
        
$this->assertTrue($result == $expected,'http://example.org/');
        
        
$result $this->wikini->Format('http://www.example.org');
        
$expected '<a href="http://www.example.org">http://www.example.org</a>';
        
$this->assertTrue($result == $expected,'http://www.example.org');
        
        
$result $this->wikini->Format('http://http.example.org');
        
$expected '<a href="http://http.example.org">http://http.example.org</a>';
        
$this->assertTrue($result == $expected,'http://http.example.org');        
    
        
$result $this->wikini->Format('http://ftp.example.org');
        
$expected '<a href="http://ftp.example.org">http://ftp.example.org</a>';
        
$this->assertTrue($result == $expected,'http://ftp.example.org');
        
        
$result $this->wikini->Format('http://example.org/Test');
        
$expected '<a href="http://example.org/Test">http://example.org/Test</a>';
        
$this->assertTrue($result == $expected,'http://example.org/Test');
        
        
$result $this->wikini->Format('http://example.org/TestTest');
        
$expected '<a href="http://example.org/TestTest">http://example.org/TestTest</a>';
        
$this->assertTrue($result == $expected,'http://example.org/TestTest');
        
        
$result $this->wikini->Format('http://example.org/test.gif');
        
$expected '<a href="http://example.org/test.gif">http://example.org/test.gif</a>';
        
$this->assertTrue($result == $expected,'http://example.org/test.gif');
        
        
$result $this->wikini->Format('http://example.org/test.jpg');
        
$expected '<a href="http://example.org/test.jpg">http://example.org/test.jpg</a>';
        
$this->assertTrue($result == $expected,'http://example.org/test.jpg');
        
        
$result $this->wikini->Format('http://example.org/test.png');
        
$expected '<a href="http://example.org/test.png">http://example.org/test.png</a>';
        
$this->assertTrue($result == $expected,'http://example.org/test.png');

        
$result $this->wikini->Format('http://example.org/test');
        
$expected '<a href="http://example.org/test">http://example.org/test</a>';
        
$this->assertTrue($result == $expected,'http://example.org/test');
        
        
$result $this->wikini->Format('http://example.org');
        
$expected '<a href="http://example.org">http://example.org</a>';
        
$this->assertTrue($result == $expected,'http://example.org');
        
        
$result $this->wikini->Format('http://example.org/test.html');
        
$expected '<a href="http://example.org/test.html">http://example.org/test.html</a>';
        
$this->assertTrue($result == $expected,'http://example.org/test.html');
        
        
$result $this->wikini->Format('http://example.org/test.html#test');
        
$expected '<a href="http://example.org/test.html#test">http://example.org/test.html#test</a>';
        
$this->assertTrue($result == $expected,'http://example.org/test.html#test');
        
        
$result $this->wikini->Format('http://example.org/test.htmlTestTest');
        
$expected '<a href="http://example.org/test.htmlTestTest">http://example.org/test.htmlTestTest</a>';
        
$this->assertTrue($result == $expected,'http://example.org/test.htmlTestTest');
        
        
$result $this->wikini->Format('http://wiki.crao.net/index.php/WebS%E9mantique');
        
$expected '<a href="http://wiki.crao.net/index.php/WebS%E9mantique">http://wiki.crao.net/index.php/WebS%E9mantique</a>';
        
$this->assertTrue($result == $expected,'http://wiki.crao.net/index.php/WebS%E9mantique');

        
$result $this->wikini->Format('http://wiki.crao.net/index.php/WebSémantique');
        
// Branche 0.4
        
$expected_04 '<a href="http://wiki.crao.net/index.php/WebSémantique">http://wiki.crao.net/index.php/WebSémantique</a>';
        
// Branche 0.5
        
$expected_05 '<a href="http://wiki.crao.net/index.php/WebS&eacute;mantique">http://wiki.crao.net/index.php/WebS&eacute;mantique</a>';
        
$this->assertTrue(($result == $expected_04) || ($result == $expected_05),'http://wiki.crao.net/index.php/WebSémantique');
        
        
$result $this->wikini->Format('http://login@example.org');
        
$expected '<a href="http://login@example.org">http://login@example.org</a>';
        
$this->assertTrue($result == $expected,'http://login@example.org');
        
        
$result $this->wikini->Format('[[http://login@example.org]]');
        
$expected '<a href="http://login@example.org">http://login@example.org</a>';
        
$this->assertTrue($result == $expected,'[[http://login@example.org]]');
    
        
$result $this->wikini->Format('http://login@example.org:8100');
        
$expected '<a href="http://login@example.org:8100">http://login@example.org:8100</a>';
        
$this->assertTrue($result == $expected,'http://login@example.org:8100');
        
        
$result $this->wikini->Format('[[http://login@example.org:8100]]');
        
$expected '<a href="http://login@example.org:8100">http://login@example.org:8100</a>';
        
$this->assertTrue($result == $expected,'[[http://login@example.org:8100]]');
        
        
$result $this->wikini->Format('http://login:pass@example.org');
        
$expected '<a href="http://login:pass@example.org">http://login:pass@example.org</a>';
        
$this->assertTrue($result == $expected,'http://login:pass@example.org');
        
        
$result $this->wikini->Format('[[http://login:pass@example.org]]');
        
$expected '<a href="http://login:pass@example.org">http://login:pass@example.org</a>';
        
$this->assertTrue($result == $expected,'[[http://login:pass@example.org]]');
        
        
        
$result $this->wikini->Format('http://login:pass@example.org:8100');
        
$expected '<a href="http://login:pass@example.org:8100">http://login:pass@example.org:8100</a>';
        
$this->assertTrue($result == $expected,'http://login@example.org:8100');
        
        
$result $this->wikini->Format('[[http://login:pass@example.org:8100]]');
        
$expected '<a href="http://login:pass@example.org:8100">http://login:pass@example.org:8100</a>';
        
$this->assertTrue($result == $expected,'[[http://login:pass@example.org:8100]]');
        
        
    }
    
    function 
test_mailto() {
        
    }
    
    function 
test_html_thingies() {
    

        
//&(?!(\#[xX][a-fA-F0-9]+|\#[0-9]+|[a-zA-Z0-9]+);)
        
        
$result $this->wikini->Format('<');
        
$expected '&lt;';
        
$this->assertTrue($result == $expected,'<');
        
        
$result $this->wikini->Format('>');
        
$expected '&gt;';
        
$this->assertTrue($result == $expected,'>');
        
        
$result $this->wikini->Format('&');
        
$expected '&amp;';
        
$this->assertTrue($result == $expected,'&');

        
$result $this->wikini->Format('"');
        
$expected '&quot;';
        
$this->assertTrue($result == $expected,'"');
        
        
    }
    
    function 
test_entities() {

        
$result $this->wikini->Format('&bla');
        
$expected '&amp;bla';
        
$this->assertTrue($result == $expected,'&bla');

        
$result $this->wikini->Format('& bla');
        
$expected '&amp; bla';
        
$this->assertTrue($result == $expected,'& bla');

    
        
$result $this->wikini->Format('&&');
        
$expected '&amp;&amp;';
        
$this->assertTrue($result == $expected,'&&');

        
$result $this->wikini->Format('&&&');
        
$expected '&amp;&amp;&amp;';
        
$this->assertTrue($result == $expected,'&&&');

        
$result $this->wikini->Format('&nbsp;&cent;&curren;&brvbar;&uml;&ordf;&not;&reg;&deg;&sup2;&acute;&para;&cedil;&ordm;&frac14;&frac34;&Agrave;&Acirc;&Auml;&AElig;&Egrave;&Ecirc;&Igrave;&Icirc;&ETH;&Ograve;&Ocirc;&Ouml;&Oslash;&Uacute;&Uuml;&THORN;&agrave;&acirc;&auml;&aelig;&egrave;&ecirc;&igrave;&icirc;&eth;&ograve;&ocirc;&ouml;&oslash;&uacute;&uuml;&thorn;');
        
$expected '&nbsp;&cent;&curren;&brvbar;&uml;&ordf;&not;&reg;&deg;&sup2;&acute;&para;&cedil;&ordm;&frac14;&frac34;&Agrave;&Acirc;&Auml;&AElig;&Egrave;&Ecirc;&Igrave;&Icirc;&ETH;&Ograve;&Ocirc;&Ouml;&Oslash;&Uacute;&Uuml;&THORN;&agrave;&acirc;&auml;&aelig;&egrave;&ecirc;&igrave;&icirc;&eth;&ograve;&ocirc;&ouml;&oslash;&uacute;&uuml;&thorn;';
        
$this->assertTrue($result == $expected,'&nbsp;&cent;&curren;&brvbar;&uml;&ordf;&not;&reg;&deg;&sup2;&acute;&para;&cedil;&ordm;&frac14;&frac34;&Agrave;&Acirc;&Auml;&AElig;&Egrave;&Ecirc;&Igrave;&Icirc;&ETH;&Ograve;&Ocirc;&Ouml;&Oslash;&Uacute;&Uuml;&THORN;&agrave;&acirc;&auml;&aelig;&egrave;&ecirc;&igrave;&icirc;&eth;&ograve;&ocirc;&ouml;&oslash;&uacute;&uuml;&thorn;');
        
        
$result $this->wikini->Format('&iexcl;&pound;&yen;&sect;&copy;&laquo;&shy;&macr;&plusmn;&sup3;&micro;&middot;&sup1;&raquo;&frac12;&iquest;&Aacute;&Atilde;&Aring;&Ccedil;&Eacute;&Euml;&Iacute;&Iuml;&Ntilde;&Oacute;&Otilde;&times;&Ugrave;&Ucirc;&Yacute;&szlig;&aacute;&atilde;&aring;&ccedil;&eacute;&euml;&iacute;&iuml;&ntilde;&oacute;&otilde;&divide;&ugrave;&ucirc;&yacute;&yuml;');
        
$expected '&iexcl;&pound;&yen;&sect;&copy;&laquo;&shy;&macr;&plusmn;&sup3;&micro;&middot;&sup1;&raquo;&frac12;&iquest;&Aacute;&Atilde;&Aring;&Ccedil;&Eacute;&Euml;&Iacute;&Iuml;&Ntilde;&Oacute;&Otilde;&times;&Ugrave;&Ucirc;&Yacute;&szlig;&aacute;&atilde;&aring;&ccedil;&eacute;&euml;&iacute;&iuml;&ntilde;&oacute;&otilde;&divide;&ugrave;&ucirc;&yacute;&yuml;';
        
$this->assertTrue($result == $expected,'&iexcl;&pound;&yen;&sect;&copy;&laquo;&shy;&macr;&plusmn;&sup3;&micro;&middot;&sup1;&raquo;&frac12;&iquest;&Aacute;&Atilde;&Aring;&Ccedil;&Eacute;&Euml;&Iacute;&Iuml;&Ntilde;&Oacute;&Otilde;&times;&Ugrave;&Ucirc;&Yacute;&szlig;&aacute;&atilde;&aring;&ccedil;&eacute;&euml;&iacute;&iuml;&ntilde;&oacute;&otilde;&divide;&ugrave;&ucirc;&yacute;&yuml;');
        
        
$result =$this->wikini->Format('&#1234;');
        
$expected '&#1234;';
        
$this->assertTrue($result == $expected,'&1234;');
        
    }
    
    function 
test_Images() {
        
        
        
// gif 
        
$result $this->wikini->Format('[[http://www.wikini.net/wikini.gif WikiniGif]]');
        
$expected '<img src="http://www.wikini.net/wikini.gif" alt="WikiniGif"/>';
        
$this->assertTrue($result == $expected,'[[http://www.wikini.net/wikini.gif WikiniGif]]');

        
// jpeg 
        
$result $this->wikini->Format('[[http://www.wikini.net/wikini.jpeg WikiniJpeg]]');
        
$expected '<img src="http://www.wikini.net/wikini.jpeg" alt="WikiniJpeg"/>';
        
$this->assertTrue($result == $expected,'[[http://www.wikini.net/wikini.jpeg WikiniJpeg]]');

        
// jpg 
        
$result $this->wikini->Format('[[http://www.wikini.net/wikini.jpg WikiniJpg]]');
        
$expected '<img src="http://www.wikini.net/wikini.jpg" alt="WikiniJpg"/>';
        
$this->assertTrue($result == $expected,'[[http://www.wikini.net/wikini.jpg WikiniJpg]]');

        
// JpG
        
$result $this->wikini->Format('[[http://www.wikini.net/wikini.JpG WikiniJpG]]');
        
$expected '<img src="http://www.wikini.net/wikini.JpG" alt="WikiniJpG"/>';
        
$this->assertTrue($result == $expected,'[[http://www.wikini.net/wikini.JpG WikiniJpG]]');

        
// png
        
$result $this->wikini->Format('[[http://www.wikini.net/wikini.png WikiniPng]]');
        
$expected '<img src="http://www.wikini.net/wikini.png" alt="WikiniPng"/>';
        
$this->assertTrue($result == $expected,'[[http://www.wikini.net/wikini.png WikiniPng]]');

    }
        
    function 
test_MotWiki() {
        
        
$result $this->wikini->Format('mot');
        
$expected 'mot';
        
$this->assertTrue($result == $expected,'mot');
    
        
$result $this->wikini->Format('MOT');
        
$expected 'MOT';
        
$this->assertTrue($result == $expected,'MOT');
    
        
$result $this->wikini->Format('MoT');
        
$pattern '/<a href="http:\/\/.*MoT.*/';
        
$this->assertRegExp($pattern,$result,'MoT');
        
        
$result $this->wikini->Format('MOt');
        
$expected 'MOt';
        
$this->assertTrue($result == $expected,'MOt');
    
        
$result $this->wikini->Format('1MO');
        
$expected '1MO';
        
$this->assertTrue($result == $expected,'1MO');
    
        
$result $this->wikini->Format('MotW');
        
$pattern '/<a href="http:\/\/.*MotW.*/';
        
$this->assertRegExp($pattern,$result,'MotW');
        
        
$result $this->wikini->Format('MoWi');
        
$pattern '/<a href="http:\/\/.*MoWi.*/';
        
$this->assertRegExp($pattern,$result,'MoWi');
        
        
$result $this->wikini->Format('MotWiki');
        
$pattern '/<a href="http:\/\/.*MotWiki.*/';
        
$this->assertRegExp($pattern,$result,'MotWiki');
        
        
$result $this->wikini->Format('MotWIKI');
        
$pattern '/<a href="http:\/\/.*MotWIKI.*/';
        
$this->assertRegExp($pattern,$result,'MotWIKI');
        
        
$result $this->wikini->Format('mot');
        
$expected 'mot';
        
$this->assertTrue($result == $expected,'mot');
    
        
$result $this->wikini->Format('MOTWiki');
        
$expected 'MOTWiki';
        
$this->assertTrue($result == $expected,'MOTWiki');
    
        
$result $this->wikini->Format('Mot_Wiki');
        
$expected 'Mot_Wiki';
        
$this->assertTrue($result == $expected,'Mot_Wiki');
        
        
$result $this->wikini->Format('Mot(Wiki)');
        
$expected 'Mot(Wiki)';
        
$this->assertTrue($result == $expected,'Mot(Wiki)');
        
        
$result $this->wikini->Format('Mot2Wiki');
        
$pattern '/<a href="http:\/\/.*Mot2Wiki.*/';
        
$this->assertRegExp($pattern,$result,'Mot2Wiki');
        
        
$result $this->wikini->Format('Mot2wiki');
        
$pattern '/<a href="http:\/\/.*Mot2wiki.*/';
        
$this->assertRegExp($pattern,$result,'Mot2wiki');
        
        
$result $this->wikini->Format('motWiki');
        
$expected 'motWiki';
        
$this->assertTrue($result == $expected,'motWiki');
    
        
$result $this->wikini->Format('MotWiki2');
        
$pattern '/<a href="http:\/\/.*MotWiki2.*/';
        
$this->assertRegExp($pattern,$result,'MotWiki2');
        
        
// Wikini ne sait pas traiter correctement les accents
        
        
$result $this->wikini->Format('MotAccentué');
        
$pattern '/<a href="http:\/\/.*MotAccentu%E9.*/';
        
$this->assertRegExp($pattern,$result,'(OK) MotAccentué');
    
        
$result $this->wikini->Format('TouchéCoulé');
        
$pattern '/<a href="http:\/\/.*Touch%E9Coul%E9.*/';
        
$this->assertRegExp($pattern,$result,'(OK) TouchéCoulé');

        
$result $this->wikini->Format('ÉditerColler');
        
$pattern '/<a href="http:\/\/.*%C9diterColler.*/';
        
$this->assertRegExp($pattern,$result,'(OK) ÉditerColler');
    
        
$result $this->wikini->Format('ÉditerÉté');
        
$pattern '/<a href="http:\/\/.*%C9diter%C9t%E9.*/';
        
$this->assertRegExp($pattern,$result,'(OK) ÉditerÉté');
    
        
$result $this->wikini->Format('Éditer2Coller');
        
$pattern '/<a href="http:\/\/.*%C9diter2Coller.*/';
        
$this->assertRegExp($pattern,$result,'(OK) Éditer2Coller');

        
$result $this->wikini->Format('2ÉditerColler');
        
$pattern '/<a href="http:\/\/.*2%C9diterColler.*/';
        
$this->assertRegExp($pattern,$result,'(OK) 2ÉditerColler');
        
        
$result $this->wikini->Format('ÉtéHiver2');
        
$pattern '/<a href="http:\/\/.*%C9diterColler.*/';
        
$this->assertRegExp($pattern,$result,'(OK) ÉtéHiver2');
        
        
$result $this->wikini->Format('ÉtéHiver2004');
        
$pattern '/<a href="http:\/\/.*%C9t%E9Hiver2004.*/';
        
$this->assertRegExp($pattern,$result,'(OK) ÉtéHiver2004');

        
$result $this->wikini->Format('Été2');
        
$pattern '/<a href="http:\/\/.*%C9t%E92.*/';
        
$this->assertRegExp($pattern,$result,'(OK) Été2');

        
$result $this->wikini->Format('Été2004');
        
$pattern '/<a href="http:\/\/.*%C9t%E92004.*/';
        
$this->assertRegExp($pattern,$result,'(OK) Été2004');

    }
    
    function 
test_Longueur_MotWiki() {
            
        
// Longueur = 10 
        
$result $this->wikini->Format('Moo10Wiiki');
        
$pattern '/<a href="http:\/\/.*Moo10Wiiki.*/';
        
$this->assertRegExp($pattern,$result,'Moo10Wiiki');
        
        
// Longueur = 50
        
$result $this->wikini->Format('Moo50WiikiMoootWiikiMoootWiikiMoootWiikiMoootWiiki');
        
$pattern '/<a href="http:\/\/.*Moo50WiikiMoootWiikiMoootWiikiMoootWiikiMoootWiiki.*/';
        
$this->assertRegExp($pattern,$result,'Moo50WiikiMoootWiikiMoootWiikiMoootWiikiMoootWiiki');
        
        
// Longueur = 60 (refusé)
        
$result $this->wikini->Format('Moo60WiikiMoootWiikiMoootWiikiMoootWiikiMoootWiikiMoootWiiki');
        
$pattern '/<a href="http:\/\/.*Moo60WiikiMoootWiikiMoootWiikiMoootWiikiMoootWiikiMoootWiiki.*/';
        
$this->assertRegExp($pattern,$result,'Moo60WiikiMoootWiikiMoootWiikiMoootWiikiMoootWiikiMoootWiiki');
        
//print $result;
    
}    

    function 
test_Ponctuation_MotWiki() {    
        
        
$result $this->wikini->Format('(MotWiki)');
        
$pattern '/\(<a href="http:\/\/.*MotWiki.*\)/';
        
$this->assertRegExp($pattern,$result,'(MotWiki)');
        
        
$result $this->wikini->Format('[MotWiki]');
        
$pattern '/\[<a href="http:\/\/.*MotWiki.*\]/';
        
$this->assertRegExp($pattern,$result,'[MotWiki]');

        
$result $this->wikini->Format('{MotWiki}');
        
$pattern '/\{<a href="http:\/\/.*MotWiki.*\}/';
        
$this->assertRegExp($pattern,$result,'{MotWiki}');
        
        
$result $this->wikini->Format('"MotWiki"');
        
$pattern '/&quot;<a href="http:\/\/.*MotWiki.*&quot;/';
        
$this->assertRegExp($pattern,$result,'"MotWiki"');
        
        
$result $this->wikini->Format('\'MotWiki\'');
        
$pattern '/\'<a href="http:\/\/.*MotWiki.*\'/';
        
$this->assertRegExp($pattern,$result,'\'MotWiki\'');
        
        
$result $this->wikini->Format('$MotWiki$');
        
$pattern '/\$<a href="http:\/\/.*MotWiki.*\$/';
        
$this->assertRegExp($pattern,$result,'$MotWiki$');
        
        
$result $this->wikini->Format('MotWiki,');
        
$pattern '/<a href="http:\/\/.*MotWiki.*,/';
        
$this->assertRegExp($pattern,$result,'MotWiki,');
                
        
$result $this->wikini->Format('MotWiki;');
        
$pattern '/<a href="http:\/\/.*MotWiki.*;/';
        
$this->assertRegExp($pattern,$result,'MotWiki;');
        
        
$result $this->wikini->Format('MotWiki:');
        
$pattern '/<a href="http:\/\/.*MotWiki.*:/';
        
$this->assertRegExp($pattern,$result,'MotWiki:');
        
        
$result $this->wikini->Format('MotWiki!');
        
$pattern '/<a href="http:\/\/.*MotWiki.*!/';
        
$this->assertRegExp($pattern,$result,'MotWiki!');
        
        
$result $this->wikini->Format('MotWiki!');
        
$pattern '/<a href="http:\/\/.*MotWiki.*!/';
        
$this->assertRegExp($pattern,$result,'MotWiki!');

        
$result $this->wikini->Format('MotWiki?');
        
$pattern '/<a href="http:\/\/.*MotWiki.*\?/';
        
$this->assertRegExp($pattern,$result,'MotWiki?');

        
$result $this->wikini->Format('MotWiki|MotWiki');
        
$pattern '/<a href="http:\/\/.*MotWiki.*\|<a href="http:\/\/.*MotWiki.*/';
        
$this->assertRegExp($pattern,$result,'MotWiki|MotWiki');
        
        
$result $this->wikini->Format('MotWiki#MotWiki');
        
$pattern '/<a href="http:\/\/.*MotWiki.*#<a href="http:\/\/.*MotWiki.*/';
        
$this->assertRegExp($pattern,$result,'MotWiki#MotWiki');

        
$result $this->wikini->Format('~MotWiki');
        
$pattern '/~<a href="http:\/\/.*MotWiki.*/';
        
$this->assertRegExp($pattern,$result,'~MotWiki');
        
        
$result $this->wikini->Format('MotWiki-MotWiki');
        
$pattern '/<a href="http:\/\/.*MotWiki.*\-<a href="http:\/\/.*MotWiki.*/';
        
$this->assertRegExp($pattern,$result,'MotWiki-MotWiki');
        
        
$result $this->wikini->Format('MotWiki.');
        
$pattern '/<a href="http:\/\/.*MotWiki.*\./';
        
$this->assertRegExp($pattern,$result,'MotWiki.');
        
        
$result $this->wikini->Format('¿MotWiki?');
        
$pattern '/¿<a href="http:\/\/.*MotWiki.*\?/';
        
$this->assertRegExp($pattern,$result,'¿MotWiki?');


    }
    
    function 
test_Divers_MotWiki() {

    
// bug branche wikini 0.4
        
$result $this->wikini->Format('Abc,Def');
        
$expected 'Abc,Def';
        
$this->assertTrue($result == $expected,'Abc,Def');
        
    }
    
    function 
test_Listes() {
        
    
    
$list=
        
    
"   - indentation de premier niveau (avec 3 espaces)\n".
    
"   - indentation de premier niveau (avec 3 espaces)\n".
    
"   - indentation de premier niveau (avec 3 espaces)\n".
    
"   - indentation de premier niveau (avec 3 espaces)\n".
    
"   - indentation de premier niveau (avec 3 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ul>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ul>";


    
$this->assertTrue($result == $expected,'Liste1');
    
        
    
$list=
        
    
"    - indentation de premier niveau (avec 1 tabulation)\n".
    
"    - indentation de premier niveau (avec 1 tabulation)\n".
    
"    - indentation de premier niveau (avec 1 tabulation)\n".
    
"    - indentation de premier niveau (avec 1 tabulation)\n".
    
"    - indentation de premier niveau (avec 1 tabulation)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ul>\n".
    
"<li> indentation de premier niveau (avec 1 tabulation)</li>\n".
    
"<li> indentation de premier niveau (avec 1 tabulation)</li>\n".
    
"<li> indentation de premier niveau (avec 1 tabulation)</li>\n".
    
"<li> indentation de premier niveau (avec 1 tabulation)</li>\n".
    
"<li> indentation de premier niveau (avec 1 tabulation)</li>\n".
    
"</ul>";


    
$this->assertTrue($result == $expected,'Liste2');
        
    
$list=
    
"   - indentation de premier niveau (avec 3 espaces)\n".
    
"     - indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"   - indentation de premier niveau (avec 3 espaces)\n".
    
"     - indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"     - indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"     - indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"          - indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"          - indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"          - indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ul>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ul>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ul>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"<ul>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"</ul>";
    
    
$this->assertTrue($result == $expected,'Liste3');

    
$list=
    
"            - indentation de premier niveau (avec 3 tabulations)\n".
    
"                    - indentation de deuxième niveau (avec 3 + 2 tabulations)\n".
    
"            - indentation de premier niveau (avec 3 tabulations)\n".
    
"                    - indentation de deuxième niveau (avec 3 + 2 tabulations)\n".
    
"                    - indentation de deuxième niveau (avec 3 + 2 tabulations)\n".
    
"                    - indentation de deuxième niveau (avec 3 + 2 tabulations)\n".
    
"                                        - indentation de troisième niveau (avec 3 + 2 + 5 tabulations)\n".
    
"                                        - indentation de troisième niveau (avec 3 + 2 + 5 tabulations)\n".
    
"                                        - indentation de troisième niveau (avec 3 + 2 + 5 tabulations)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ul>\n".
    
"<li> indentation de premier niveau (avec 3 tabulations)\n".
    
"<ul>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 tabulations)</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 tabulations)\n".
    
"<ul>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 tabulations)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 tabulations)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 tabulations)\n".
    
"<ul>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 tabulations)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 tabulations)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 tabulations)</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"</ul>";
    
    
$this->assertTrue($result == $expected,'Liste4');

    
//
    
    
$list=
    
" - 1\n".
    
"   - 3\n".
    
"     - 5\n".
    
"       - 7\n".
    
" - 1\n".
    
"       - 7\n".
    
"     - 5";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ul>\n".
    
"<li> 1\n".
    
"<ul>\n".
    
"<li> 3\n".
    
"<ul>\n".
    
"<li> 5\n".
    
"<ul>\n".
    
"<li> 7</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"<li> 1\n".
    
"<ul>\n".
    
"<li> 7</li>\n".
    
"<li> 5</li>\n".
    
"</ul>\n".
    
"</li>\n".
    
"</ul>";

    
$this->assertTrue($result == $expected,'Liste5');

    
$list=
    
"   1) indentation de premier niveau (avec 3 espaces)\n".
    
"   1) indentation de premier niveau (avec 3 espaces)\n".
    
"   1) indentation de premier niveau (avec 3 espaces)\n".
    
"   1) indentation de premier niveau (avec 3 espaces)\n".
    
"   1) indentation de premier niveau (avec 3 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ol style=\"list-style: decimal;\">\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ol>";

    
$this->assertTrue($result == $expected,'Liste6');          
    
    
$list=
    
"   a) indentation de premier niveau (avec 3 espaces)\n".
    
"   a) indentation de premier niveau (avec 3 espaces)\n".
    
"   a) indentation de premier niveau (avec 3 espaces)\n".
    
"   a) indentation de premier niveau (avec 3 espaces)\n".
    
"   a) indentation de premier niveau (avec 3 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ol style=\"list-style: lower-alpha;\">\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ol>";

    
$this->assertTrue($result == $expected,'Liste7');                         
    
    
$list=
    
"   A) indentation de premier niveau (avec 3 espaces)\n".
    
"   A) indentation de premier niveau (avec 3 espaces)\n".
    
"   A) indentation de premier niveau (avec 3 espaces)\n".
    
"   A) indentation de premier niveau (avec 3 espaces)\n".
    
"   A) indentation de premier niveau (avec 3 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ol style=\"list-style: upper-alpha;\">\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ol>";

    
$this->assertTrue($result == $expected,'Liste8');
    
    
        
    
$list=
    
"   i) indentation de premier niveau (avec 3 espaces)\n".
    
"   i) indentation de premier niveau (avec 3 espaces)\n".
    
"   i) indentation de premier niveau (avec 3 espaces)\n".
    
"   i) indentation de premier niveau (avec 3 espaces)\n".
    
"   i) indentation de premier niveau (avec 3 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ol style=\"list-style: lower-roman;\">\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ol>";

    
$this->assertTrue($result == $expected,'Liste9');          
    
            
    
$list=
    
"   I) indentation de premier niveau (avec 3 espaces)\n".
    
"   I) indentation de premier niveau (avec 3 espaces)\n".
    
"   I) indentation de premier niveau (avec 3 espaces)\n".
    
"   I) indentation de premier niveau (avec 3 espaces)\n".
    
"   I) indentation de premier niveau (avec 3 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ol style=\"list-style: upper-roman;\">\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ol>";

    
$this->assertTrue($result == $expected,'Liste10');          
    
    
$list=
    
"   1) indentation de premier niveau (avec 3 espaces)\n".
    
"     i) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"     i) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"   1) indentation de premier niveau (avec 3 espaces)\n".
    
"     a) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"     a) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"     a) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"          I) indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"          I) indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"          I) indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"   1) indentation de premier niveau (avec 3 espaces)\n".
    
"     1) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"     1) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"     1) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"   1) indentation de premier niveau (avec 3 espaces)\n";

    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ol style=\"list-style: decimal;\">\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ol style=\"list-style: lower-roman;\">\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ol style=\"list-style: lower-alpha;\">\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"<ol style=\"list-style: upper-roman;\">\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ol style=\"list-style: decimal;\">\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ol>";                      
    
    
$this->assertTrue($result == $expected,'Liste11');

    
$list=
    
"            1) indentation de premier niveau (avec 3 espaces)\n".
    
"                    i) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"                    i) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"            1) indentation de premier niveau (avec 3 espaces)\n".
    
"                    a) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"                    a) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"                    a) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"                                        I) indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"                                        I) indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"                                        I) indentation de troisième niveau (avec 3 + 2 + 5 espaces)\n".
    
"            1) indentation de premier niveau (avec 3 espaces)\n".
    
"                    1) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"                    1) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"                    1) indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"            1) indentation de premier niveau (avec 3 espaces)\n";

    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ol style=\"list-style: decimal;\">\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ol style=\"list-style: lower-roman;\">\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ol style=\"list-style: lower-alpha;\">\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)\n".
    
"<ol style=\"list-style: upper-roman;\">\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"<li> indentation de troisième niveau (avec 3 + 2 + 5 espaces)</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)\n".
    
"<ol style=\"list-style: decimal;\">\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"<li> indentation de deuxième niveau (avec 3 + 2 espaces)</li>\n".
    
"</ol>\n".
    
"</li>\n".
    
"<li> indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ol>";                      
    
    
$this->assertTrue($result == $expected,'Liste12');

    
$list=
        
    
"   indentation de premier niveau (avec 3 espaces)\n".
    
"   indentation de premier niveau (avec 3 espaces)\n".
    
"   indentation de premier niveau (avec 3 espaces)\n".
    
"   indentation de premier niveau (avec 3 espaces)\n".
    
"   indentation de premier niveau (avec 3 espaces)\n";
    
    
$result $this->wikini->Format($list);
    
    
$expected =
    
"<ul style=\"list-style: none; \">\n".
    
"<li>indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li>indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li>indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li>indentation de premier niveau (avec 3 espaces)</li>\n".
    
"<li>indentation de premier niveau (avec 3 espaces)</li>\n".
    
"</ul>";


    
$this->assertTrue($result == $expected,'Liste13');
    

    
$list=
        
" 1\n".
        
"   3\n".
        
"     5\n".
        
"       7\n".
        
" 1\n".
        
"       7\n".
        
"     5\n";

    
$result $this->wikini->Format($list);
    
    
$expected =
        
"<ul style=\"list-style: none; \">\n".
        
"<li>1\n".
        
"<ul style=\"list-style: none; \">\n".
        
"<li>3\n".
        
"<ul style=\"list-style: none; \">\n".
        
"<li>5\n".
        
"<ul style=\"list-style: none; \">\n".
        
"<li>7</li>\n".
        
"</ul>\n".
        
"</li>\n".
        
"</ul>\n".
        
"</li>\n".
        
"</ul>\n".
        
"</li>\n".
        
"<li>1\n".
        
"<ul style=\"list-style: none; \">\n".
        
"<li>7</li>\n".
        
"<li>5</li>\n".
        
"</ul>\n".
        
"</li>\n".
        
"</ul>";


    
$this->assertTrue($result == $expected,'Liste14');
    
    
    
    }

}                                
?>


<?php

// wikinitest.php à inclure à la racine du wikini à tester

require_once 'testcase.php';
require_once 
'PHPUnit.php';

$suite  = new PHPUnit_TestSuite("WikiniTest");
$result PHPUnit::run($suite);

echo 
$result->toHtml();
?>


Et appel, au moyen d'un navigateur, de testcase.php pour lancer le test, le résultat attendu est le suivant :

TestCase wikinitest->test_url_simple() passed
TestCase wikinitest->test_texte() passed

Pour de petits cas comme cela, c'est efficace mais je crois qu'on aura de toute façon besoin de valider des pages complètes pour voir comment tout fonctionne "ensemble". Par ailleurs le résultat en sortie peut aussi varier légèrement (retours à la ligne dans le texte, changement dans les balises html employées etc.) ou beaucoup (résultat des actions etc.). Or ce qui compte c'est principalement deux choses:
Le deuxième pourraît être testé de manière automatique mais pas le premier en tout cas...
-- LordFarquaad

Bien sûr, il y a des choses qui seront difficillement testable par ce moyen, mais ça permet toutefois de bien déblayer le terrain et pas forcemment que pour de "petits cas".
-> Voir le programme testcase.php ci-dessus, bien pratique pour tester les modifications de formatter -- DavidDelon


Un grand bravo David et LordFarquaad pour ces propositions. Je recommande très chaudement la lecture du "Précis et concis" Extreme programming chez O'Reilly qui est une introduction très précieuse et très synthétique à l'XP. Je révais même de programmation en bynôme à distance (cf. http://www.onpk.net/index.php/2005/03/31/278-les-inconvenients-de-la-programmation-en-binome ) -- CharlesNepote


CharlesNepoteASuivreEnPriorite


Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]