changeset 18:267ffe3e76f5

Ajout d'une structure de tests unitaires On utilise les différents exemples présents comme des tests unitaires, et on ajoute des rendus de références pour chacun, de façon à vérifier que tout se passe bien.
author Franck Deroche <webmaster@defr.org>
date Tue, 30 Oct 2007 15:06:30 +0100
parents d4ac7cef0cdd
children fb0e206f1acf
files .hgignore tests/references/blog.out tests/references/menu.out tests/references/simple.out tests/test.sh
diffstat 5 files changed, 74 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Wed Oct 24 20:49:32 2007 +0200
+++ b/.hgignore	Tue Oct 30 15:06:30 2007 +0100
@@ -1,2 +1,4 @@
 (.*)~$
 (.*)\.swp$
+glob:tests/tmp
+glob:tests/tmpdiff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/references/blog.out	Tue Oct 30 15:06:30 2007 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:tr="http://defr.net/2007/template" xml:lang="fr">
+  <head>
+    <title>Dual Blog</title>
+    <link rel="StyleSheet" type="Text/CSS" href="/blog/css/comment.css"/>
+    <link type="text/css" media="screen" rel="StyleSheet" href="/css/truc.css" title="Truc"/>
+    <link type="text/css" media="screen" rel="Alternate StyleSheet" href="/css/chose.css" title="Chose"/>
+    <link rel="alternate" type="application/atom+xml" title="Atom feed" href="/blog/dualblog.atom"/>
+    <link rel="alternate" type="application/rss+xml" title="RSS 2.0 feed" href="/blog/dualblog.rss"/>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <meta name="author" content="Franck Deroche"/>
+  </head>
+  <body id="Main">
+    <h1>Dual Blog : DeFr's Weblog</h1>
+    <div id="Posts" tr:id="Posts">
+      <div class="PostContent Weird" tr:id="post"><h2>Lorem ipsum | <span class="Date">lundi 19 mars 2007, 00h37</span></h2><img tr:id="mood" class="mood" src="/blog/mood/Weird.png" alt="Mood: Weird"/>Lorem ipsum sit dolor amet<p class="postInfos"><span class="Tags"><em>Tags</em> : Voyage, Toulon, SNCF</span><br/><a href="/blog/posts/321-Une_nuit_en_Corail_Lunea">#0002</a> - 
+	<a href="/blog/posts/321-Une_nuit_en_Corail_Lunea">Un petit commentaire ?</a>
+	</p></div>
+      <div class="PostContent Cool" tr:id="post"><h2>Sit dolor | <span class="Date">samedi 17 mars 2007, 00h37</span></h2><img tr:id="mood" class="mood" src="/blog/mood/Cool.png" alt="Mood: Cool"/>sit dolor amet<p class="postInfos"><span class="Tags"><em>Tags</em> : Voyage, Toulon, SNCF</span><br/><a href="/blog/posts/321-Une_nuit_en_Corail_Lunea">#0001</a> - 
+	<a href="/blog/posts/321-Une_nuit_en_Corail_Lunea">Un petit commentaire ?</a>
+	</p></div>
+    </div>
+  </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/references/menu.out	Tue Oct 30 15:06:30 2007 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<dl xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://defr.net/2007/template" t:id="monMenu">
+  <wrapper dt="Test1" dd="Truc1">
+    <dt/>
+    <dd/>
+  </wrapper>
+  <wrapper dt="Test2" dd="Truc2">
+    <dt/>
+    <dd/>
+  </wrapper>
+</dl>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/references/simple.out	Tue Oct 30 15:06:30 2007 +0100
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://defr.net/2007/template" xml:lang="fr">
+  <head>
+    <title>Ceci est un test</title>
+  </head>
+  <body>
+    <h1 t:id="hello" class="test3">Bonjour tout l'monde!</h1>
+    <p>Ceci devrait remplacer l'element test dans l'espace de nom t.</p>
+    <p>Ma couleur préférée est le vert. Et vous ?</p>
+    <p t:id="attr" class="test">Test sur les attributs.</p>
+    <ul t:id="choses">
+      <li>Première chose</li>
+      <li class="test">Lorem ipsum</li>
+      <li class="ab">sit dolor</li>
+      <li class="ab">amet.</li>
+      <li>Dernière chose</li>
+    </ul>
+    <span></span>
+  </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test.sh	Tue Oct 30 15:06:30 2007 +0100
@@ -0,0 +1,15 @@
+#!/bin/sh
+TESTS="blog menu simple"
+TEMPFILE=tmp
+DIFFFILE=tmpdiff
+for T in $TESTS; do
+  echo -n "Test de $T"
+  php -f ../$T.php > $TEMPFILE
+  diff -u references/$T.out $TEMPFILE > $DIFFFILE
+  if [ $? -eq 0 ]; then
+	echo "	    [ok]"
+  else
+  	echo "	[failed]"
+	cat $DIFFFILE
+  fi
+done