aboutsummaryrefslogtreecommitdiff
path: root/vendors/simpletest/docs
diff options
context:
space:
mode:
Diffstat (limited to 'vendors/simpletest/docs')
-rw-r--r--vendors/simpletest/docs/en/authentication_documentation.html355
-rw-r--r--vendors/simpletest/docs/en/browser_documentation.html447
-rw-r--r--vendors/simpletest/docs/en/docs.css121
-rw-r--r--vendors/simpletest/docs/en/expectation_documentation.html422
-rw-r--r--vendors/simpletest/docs/en/form_testing_documentation.html342
-rw-r--r--vendors/simpletest/docs/en/group_test_documentation.html386
-rw-r--r--vendors/simpletest/docs/en/index.html538
-rw-r--r--vendors/simpletest/docs/en/mock_objects_documentation.html757
-rw-r--r--vendors/simpletest/docs/en/overview.html486
-rw-r--r--vendors/simpletest/docs/en/partial_mocks_documentation.html445
-rw-r--r--vendors/simpletest/docs/en/reporter_documentation.html519
-rw-r--r--vendors/simpletest/docs/en/unit_test_documentation.html431
-rw-r--r--vendors/simpletest/docs/en/web_tester_documentation.html584
-rw-r--r--vendors/simpletest/docs/fr/authentication_documentation.html332
-rw-r--r--vendors/simpletest/docs/fr/browser_documentation.html446
-rw-r--r--vendors/simpletest/docs/fr/docs.css84
-rw-r--r--vendors/simpletest/docs/fr/expectation_documentation.html383
-rw-r--r--vendors/simpletest/docs/fr/form_testing_documentation.html349
-rw-r--r--vendors/simpletest/docs/fr/group_test_documentation.html398
-rw-r--r--vendors/simpletest/docs/fr/index.html572
-rw-r--r--vendors/simpletest/docs/fr/mock_objects_documentation.html778
-rw-r--r--vendors/simpletest/docs/fr/overview.html318
-rw-r--r--vendors/simpletest/docs/fr/partial_mocks_documentation.html460
-rw-r--r--vendors/simpletest/docs/fr/reporter_documentation.html534
-rw-r--r--vendors/simpletest/docs/fr/server_stubs_documentation.html0
-rw-r--r--vendors/simpletest/docs/fr/unit_test_documentation.html447
-rw-r--r--vendors/simpletest/docs/fr/web_tester_documentation.html566
27 files changed, 11500 insertions, 0 deletions
diff --git a/vendors/simpletest/docs/en/authentication_documentation.html b/vendors/simpletest/docs/en/authentication_documentation.html
new file mode 100644
index 000000000..8da2a7f9e
--- /dev/null
+++ b/vendors/simpletest/docs/en/authentication_documentation.html
@@ -0,0 +1,355 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>SimpleTest documentation for testing log-in and authentication</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <span class="chosen">Authentication</span>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Authentication documentation</h1>
+ This page...
+ <ul>
+<li>
+ Getting through <a href="#basic">Basic HTTP authentication</a>
+ </li>
+<li>
+ Testing <a href="#cookies">cookie based authentication</a>
+ </li>
+<li>
+ Managing <a href="#session">browser sessions</a> and timeouts
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ One of the trickiest, and yet most important, areas
+ of testing web sites is the security.
+ Testing these schemes is one of the core goals of
+ the SimpleTest web tester.
+ </p>
+
+ <p><a class="target" name="basic"><h2>Basic HTTP authentication</h2></a></p>
+ <p>
+ If you fetch a page protected by basic authentication then
+ rather than receiving content, you will instead get a 401
+ header.
+ We can illustrate this with this test...
+<pre>
+class AuthenticationTest extends WebTestCase {<strong>
+ function test401Header() {
+ $this-&gt;get('http://www.lastcraft.com/protected/');
+ $this-&gt;showHeaders();
+ }</strong>
+}
+</pre>
+ This allows us to see the challenge header...
+ <div class="demo">
+ <h1>File test</h1>
+<pre style="background-color: lightgray; color: black">
+HTTP/1.1 401 Authorization Required
+Date: Sat, 18 Sep 2004 19:25:18 GMT
+Server: Apache/1.3.29 (Unix) PHP/4.3.4
+WWW-Authenticate: Basic realm="SimpleTest basic authentication"
+Connection: close
+Content-Type: text/html; charset=iso-8859-1
+</pre>
+ <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">1/1 test cases complete.
+ <strong>0</strong> passes, <strong>0</strong> fails and <strong>0</strong> exceptions.</div>
+ </div>
+ We are trying to get away from visual inspection though, and so SimpleTest
+ allows to make automated assertions against the challenge.
+ Here is a thorough test of our header...
+<pre>
+class AuthenticationTest extends WebTestCase {
+ function test401Header() {
+ $this-&gt;get('http://www.lastcraft.com/protected/');<strong>
+ $this-&gt;assertAuthentication('Basic');
+ $this-&gt;assertResponse(401);
+ $this-&gt;assertRealm('SimpleTest basic authentication');</strong>
+ }
+}
+</pre>
+ Any one of these tests would normally do on it's own depending
+ on the amount of detail you want to see.
+ </p>
+ <p>
+ One theme that runs through SimpleTest is the ability to use
+ <span class="new_code">SimpleExpectation</span> objects wherever a simple
+ match is not enough.
+ If you want only an approximate match to the realm for
+ example, you can do this...
+<pre>
+class AuthenticationTest extends WebTestCase {
+ function test401Header() {
+ $this-&gt;get('http://www.lastcraft.com/protected/');
+ $this-&gt;assertRealm(<strong>new PatternExpectation('/simpletest/i')</strong>);
+ }
+}
+</pre>
+ Most of the time we are not interested in testing the
+ authentication itself, but want to get past it to test
+ the pages underneath.
+ As soon as the challenge has been issued we can reply with
+ an authentication response...
+<pre>
+class AuthenticationTest extends WebTestCase {
+ function testCanAuthenticate() {
+ $this-&gt;get('http://www.lastcraft.com/protected/');<strong>
+ $this-&gt;authenticate('Me', 'Secret');</strong>
+ $this-&gt;assertTitle(...);
+ }
+}
+</pre>
+ The username and password will now be sent with every
+ subsequent request to that directory and subdirectories.
+ You will have to authenticate again if you step outside
+ the authenticated directory, but SimpleTest is smart enough
+ to merge subdirectories into a common realm.
+ </p>
+ <p>
+ You can shortcut this step further by encoding the log in
+ details straight into the URL...
+<pre>
+class AuthenticationTest extends WebTestCase {
+ function testCanReadAuthenticatedPages() {
+ $this-&gt;get('http://<strong>Me:Secret@</strong>www.lastcraft.com/protected/');
+ $this-&gt;assertTitle(...);
+ }
+}
+</pre>
+ If your username or password has special characters, then you
+ will have to URL encode them or the request will not be parsed
+ correctly.
+ Also this header will not be sent on subsequent requests if
+ you request a page with a fully qualified URL.
+ If you navigate with relative URLs though, the authentication
+ information will be preserved.
+ </p>
+ <p>
+ Only basic authentication is currently supported and this is
+ only really secure in tandem with HTTPS connections.
+ This is usually enough to protect test server from prying eyes,
+ however.
+ Digest authentication and NTLM authentication may be added
+ in the future.
+ </p>
+
+ <p><a class="target" name="cookies"><h2>Cookies</h2></a></p>
+ <p>
+ Basic authentication doesn't give enough control over the
+ user interface for web developers.
+ More likely this functionality will be coded directly into
+ the web architecture using cookies and complicated timeouts.
+ </p>
+ <p>
+ Starting with a simple log-in form...
+<pre>
+&lt;form&gt;
+ Username:
+ &lt;input type="text" name="u" value="" /&gt;&lt;br /&gt;
+ Password:
+ &lt;input type="password" name="p" value="" /&gt;&lt;br /&gt;
+ &lt;input type="submit" value="Log in" /&gt;
+&lt;/form&gt;
+</pre>
+ Which looks like...
+ </p>
+ <p>
+ <form class="demo">
+ Username:
+ <input type="text" name="u" value=""><br>
+ Password:
+ <input type="password" name="p" value=""><br>
+ <input type="submit" value="Log in">
+ </form>
+ </p>
+ <p>
+ Let's suppose that in fetching this page a cookie has been
+ set with a session ID.
+ We are not going to fill the form in yet, just test that
+ we are tracking the user.
+ Here is the test...
+<pre>
+class LogInTest extends WebTestCase {
+ function testSessionCookieSetBeforeForm() {
+ $this-&gt;get('http://www.my-site.com/login.php');<strong>
+ $this-&gt;assertCookie('SID');</strong>
+ }
+}
+</pre>
+ All we are doing is confirming that the cookie is set.
+ As the value is likely to be rather cryptic it's not
+ really worth testing this with...
+<pre>
+class LogInTest extends WebTestCase {
+ function testSessionCookieIsCorrectPattern() {
+ $this-&gt;get('http://www.my-site.com/login.php');
+ $this-&gt;assertCookie('SID', <strong>new PatternExpectation('/[a-f0-9]{32}/i')</strong>);
+ }
+}
+</pre>
+ The rest of the test would be the same as any other form,
+ but we might want to confirm that we still have the same
+ cookie after log-in as before we entered.
+ We wouldn't want to lose track of this after all.
+ Here is a possible test for this...
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testSessionCookieSameAfterLogIn() {
+ $this-&gt;get('http://www.my-site.com/login.php');<strong>
+ $session = $this-&gt;getCookie('SID');
+ $this-&gt;setField('u', 'Me');
+ $this-&gt;setField('p', 'Secret');
+ $this-&gt;click('Log in');
+ $this-&gt;assertText('Welcome Me');
+ $this-&gt;assertCookie('SID', $session);</strong>
+ }
+}
+</pre>
+ This confirms that the session identifier is maintained
+ afer log-in.
+ </p>
+ <p>
+ We could even attempt to spoof our own system by setting
+ arbitrary cookies to gain access...
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testSessionCookieSameAfterLogIn() {
+ $this-&gt;get('http://www.my-site.com/login.php');<strong>
+ $this-&gt;setCookie('SID', 'Some other session');
+ $this-&gt;get('http://www.my-site.com/restricted.php');</strong>
+ $this-&gt;assertText('Access denied');
+ }
+}
+</pre>
+ Is your site protected from this attack?
+ </p>
+
+ <p><a class="target" name="session"><h2>Browser sessions</h2></a></p>
+ <p>
+ If you are testing an authentication system a critical piece
+ of behaviour is what happens when a user logs back in.
+ We would like to simulate closing and reopening a browser...
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testLoseAuthenticationAfterBrowserClose() {
+ $this-&gt;get('http://www.my-site.com/login.php');
+ $this-&gt;setField('u', 'Me');
+ $this-&gt;setField('p', 'Secret');
+ $this-&gt;click('Log in');
+ $this-&gt;assertText('Welcome Me');<strong>
+
+ $this-&gt;restart();
+ $this-&gt;get('http://www.my-site.com/restricted.php');
+ $this-&gt;assertText('Access denied');</strong>
+ }
+}
+</pre>
+ The <span class="new_code">WebTestCase::restart()</span> method will
+ preserve cookies that have unexpired timeouts, but throw away
+ those that are temporary or expired.
+ You can optionally specify the time and date that the restart
+ happened.
+ </p>
+ <p>
+ Expiring cookies can be a problem.
+ After all, if you have a cookie that expires after an hour,
+ you don't want to stall the test for an hour while the
+ cookie passes it's timeout.
+ </p>
+ <p>
+ To push the cookies over the hour limit you can age them
+ before you restart the session...
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testLoseAuthenticationAfterOneHour() {
+ $this-&gt;get('http://www.my-site.com/login.php');
+ $this-&gt;setField('u', 'Me');
+ $this-&gt;setField('p', 'Secret');
+ $this-&gt;click('Log in');
+ $this-&gt;assertText('Welcome Me');
+ <strong>
+ $this-&gt;ageCookies(3600);</strong>
+ $this-&gt;restart();
+ $this-&gt;get('http://www.my-site.com/restricted.php');
+ $this-&gt;assertText('Access denied');
+ }
+}
+</pre>
+ After the restart it will appear that cookies are an
+ hour older and any that pass their expiry will have
+ disappeared.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
+ gives full detail on the classes and assertions available.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <span class="chosen">Authentication</span>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/browser_documentation.html b/vendors/simpletest/docs/en/browser_documentation.html
new file mode 100644
index 000000000..522f3a598
--- /dev/null
+++ b/vendors/simpletest/docs/en/browser_documentation.html
@@ -0,0 +1,447 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>SimpleTest documentation for the scriptable web browser component</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <span class="chosen">Scriptable browser</span>
+</div></div>
+<h1>PHP Scriptable Web Browser</h1>
+ This page...
+ <ul>
+<li>
+ Using the bundled <a href="#scripting">web browser in scripts</a>
+ </li>
+<li>
+ <a href="#debug">Debugging</a> failed pages
+ </li>
+<li>
+ Complex <a href="#unit">tests with multiple web browsers</a>
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ SimpleTest's web browser component can be used not just
+ outside of the <span class="new_code">WebTestCase</span> class, but also
+ independently of the SimpleTest framework itself.
+ </p>
+
+ <p><a class="target" name="scripting"><h2>The Scriptable Browser</h2></a></p>
+ <p>
+ You can use the web browser in PHP scripts to confirm
+ services are up and running, or to extract information
+ from them at a regular basis.
+ For example, here is a small script to extract the current number of
+ open PHP 5 bugs from the <a href="http://www.php.net/">PHP web site</a>...
+<pre>
+<strong>&lt;?php
+require_once('simpletest/browser.php');
+
+$browser = &amp;new SimpleBrowser();
+$browser-&gt;get('http://php.net/');
+$browser-&gt;click('reporting bugs');
+$browser-&gt;click('statistics');
+$page = $browser-&gt;click('PHP 5 bugs only');
+preg_match('/status=Open.*?by=Any.*?(\d+)&lt;\/a&gt;/', $page, $matches);
+print $matches[1];
+?&gt;</strong>
+</pre>
+ There are simpler methods to do this particular example in PHP
+ of course.
+ For example you can just use the PHP <span class="new_code">file()</span>
+ command against what here is a pretty fixed page.
+ However, using the web browser for scripts allows authentication,
+ correct handling of cookies, automatic loading of frames, redirects,
+ form submission and the ability to examine the page headers.
+ Such methods are fragile against a site that is constantly
+ evolving and you would want a more direct way of accessing
+ data in a permanent set up, but for simple tasks this can provide
+ a very rapid solution.
+ </p>
+ <p>
+ All of the navigation methods used in the
+ <a href="web_tester_documentation.html">WebTestCase</a>
+ are present in the <span class="new_code">SimpleBrowser</span> class, but
+ the assertions are replaced with simpler accessors.
+ Here is a full list of the page navigation methods...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">addHeader($header)</span></td>
+<td>Adds a header to every fetch</td>
+</tr>
+ <tr>
+<td><span class="new_code">useProxy($proxy, $username, $password)</span></td>
+<td>Use this proxy from now on</td>
+</tr>
+ <tr>
+<td><span class="new_code">head($url, $parameters)</span></td>
+<td>Perform a HEAD request</td>
+</tr>
+ <tr>
+<td><span class="new_code">get($url, $parameters)</span></td>
+<td>Fetch a page with GET</td>
+</tr>
+ <tr>
+<td><span class="new_code">post($url, $parameters)</span></td>
+<td>Fetch a page with POST</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLink($label)</span></td>
+<td>Follows a link by label</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLinkById($id)</span></td>
+<td>Follows a link by attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">getUrl()</span></td>
+<td>Current URL of page or frame</td>
+</tr>
+ <tr>
+<td><span class="new_code">getTitle()</span></td>
+<td>Page title</td>
+</tr>
+ <tr>
+<td><span class="new_code">getContent()</span></td>
+<td>Raw page or frame</td>
+</tr>
+ <tr>
+<td><span class="new_code">getContentAsText()</span></td>
+<td>HTML removed except for alt text</td>
+</tr>
+ <tr>
+<td><span class="new_code">retry()</span></td>
+<td>Repeat the last request</td>
+</tr>
+ <tr>
+<td><span class="new_code">back()</span></td>
+<td>Use the browser back button</td>
+</tr>
+ <tr>
+<td><span class="new_code">forward()</span></td>
+<td>Use the browser forward button</td>
+</tr>
+ <tr>
+<td><span class="new_code">authenticate($username, $password)</span></td>
+<td>Retry page or frame after a 401 response</td>
+</tr>
+ <tr>
+<td><span class="new_code">restart($date)</span></td>
+<td>Restarts the browser for a new session</td>
+</tr>
+ <tr>
+<td><span class="new_code">ageCookies($interval)</span></td>
+<td>Ages the cookies by the specified time</td>
+</tr>
+ <tr>
+<td><span class="new_code">setCookie($name, $value)</span></td>
+<td>Sets an additional cookie</td>
+</tr>
+ <tr>
+<td><span class="new_code">getCookieValue($host, $path, $name)</span></td>
+<td>Reads the most specific cookie</td>
+</tr>
+ <tr>
+<td><span class="new_code">getCurrentCookieValue($name)</span></td>
+<td>Reads cookie for the current context</td>
+</tr>
+ </tbody></table>
+ The methods <span class="new_code">SimpleBrowser::useProxy()</span> and
+ <span class="new_code">SimpleBrowser::addHeader()</span> are special.
+ Once called they continue to apply to all subsequent fetches.
+ </p>
+ <p>
+ Navigating forms is similar to the
+ <a href="form_testing_documentation.html">WebTestCase form navigation</a>...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">setField($name, $value)</span></td>
+<td>Sets all form fields with that name</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFieldById($id, $value)</span></td>
+<td>Sets all form fields with that id</td>
+</tr>
+ <tr>
+<td><span class="new_code">getField($name)</span></td>
+<td>Accessor for a form element value</td>
+</tr>
+ <tr>
+<td><span class="new_code">getFieldById($id)</span></td>
+<td>Accessor for a form element value</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmit($label)</span></td>
+<td>Submits form by button label</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitByName($name)</span></td>
+<td>Submits form by button attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitById($id)</span></td>
+<td>Submits form by button attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImage($label, $x, $y)</span></td>
+<td>Clicks an input tag of type image by title or alt text</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageByName($name, $x, $y)</span></td>
+<td>Clicks an input tag of type image by name</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageById($id, $x, $y)</span></td>
+<td>Clicks an input tag of type image by ID attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">submitFormById($id)</span></td>
+<td>Submits by the form tag attribute</td>
+</tr>
+ </tbody></table>
+ At the moment there aren't any methods to list available forms
+ and fields.
+ This will probably be added to later versions of SimpleTest.
+ </p>
+ <p>
+ Within a page, individual frames can be selected.
+ If no selection is made then all the frames are merged together
+ in one large conceptual page.
+ The content of the current page will be a concatenation of all of the
+ frames in the order that they were specified in the "frameset"
+ tags.
+ <table><tbody>
+ <tr>
+<td><span class="new_code">getFrames()</span></td>
+<td>A dump of the current frame structure</td>
+</tr>
+ <tr>
+<td><span class="new_code">getFrameFocus()</span></td>
+<td>Current frame label or index</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocusByIndex($choice)</span></td>
+<td>Select a frame numbered from 1</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocus($name)</span></td>
+<td>Select frame by label</td>
+</tr>
+ <tr>
+<td><span class="new_code">clearFrameFocus()</span></td>
+<td>Treat all the frames as a single page</td>
+</tr>
+ </tbody></table>
+ When focused on a single frame, the content will come from
+ that frame only.
+ This includes links to click and forms to submit.
+ </p>
+
+ <p><a class="target" name="debug"><h2>What went wrong?</h2></a></p>
+ <p>
+ All of this functionality is great when we actually manage to fetch pages,
+ but that doesn't always happen.
+ To help figure out what went wrong, the browser has some methods to
+ aid in debugging...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">setConnectionTimeout($timeout)</span></td>
+<td>Close the socket on overrun</td>
+</tr>
+ <tr>
+<td><span class="new_code">getRequest()</span></td>
+<td>Raw request header of page or frame</td>
+</tr>
+ <tr>
+<td><span class="new_code">getHeaders()</span></td>
+<td>Raw response header of page or frame</td>
+</tr>
+ <tr>
+<td><span class="new_code">getTransportError()</span></td>
+<td>Any socket level errors in the last fetch</td>
+</tr>
+ <tr>
+<td><span class="new_code">getResponseCode()</span></td>
+<td>HTTP response of page or frame</td>
+</tr>
+ <tr>
+<td><span class="new_code">getMimeType()</span></td>
+<td>Mime type of page or frame</td>
+</tr>
+ <tr>
+<td><span class="new_code">getAuthentication()</span></td>
+<td>Authentication type in 401 challenge header</td>
+</tr>
+ <tr>
+<td><span class="new_code">getRealm()</span></td>
+<td>Authentication realm in 401 challenge header</td>
+</tr>
+ <tr>
+<td><span class="new_code">setMaximumRedirects($max)</span></td>
+<td>Number of redirects before page is loaded anyway</td>
+</tr>
+ <tr>
+<td><span class="new_code">setMaximumNestedFrames($max)</span></td>
+<td>Protection against recursive framesets</td>
+</tr>
+ <tr>
+<td><span class="new_code">ignoreFrames()</span></td>
+<td>Disables frames support</td>
+</tr>
+ <tr>
+<td><span class="new_code">useFrames()</span></td>
+<td>Enables frames support</td>
+</tr>
+ <tr>
+<td><span class="new_code">ignoreCookies()</span></td>
+<td>Disables sending and receiving of cookies</td>
+</tr>
+ <tr>
+<td><span class="new_code">useCookies()</span></td>
+<td>Enables cookie support</td>
+</tr>
+ </tbody></table>
+ The methods <span class="new_code">SimpleBrowser::setConnectionTimeout()</span>
+ <span class="new_code">SimpleBrowser::setMaximumRedirects()</span>,
+ <span class="new_code">SimpleBrowser::setMaximumNestedFrames()</span>,
+ <span class="new_code">SimpleBrowser::ignoreFrames()</span>,
+ <span class="new_code">SimpleBrowser::useFrames()</span>,
+ <span class="new_code">SimpleBrowser::ignoreCookies()</span> and
+ <span class="new_code">SimpleBrowser::useCokies()</span> continue to apply
+ to every subsequent request.
+ The other methods are frames aware.
+ This means that if you have an individual frame that is not
+ loading, navigate to it using <span class="new_code">SimpleBrowser::setFrameFocus()</span>
+ and you can then use <span class="new_code">SimpleBrowser::getRequest()</span>, etc to
+ see what happened.
+ </p>
+
+ <p><a class="target" name="unit"><h2>Complex unit tests with multiple browsers</h2></a></p>
+ <p>
+ Anything that could be done in a
+ <a href="web_tester_documentation.html">WebTestCase</a> can
+ now be done in a <a href="unit_tester_documentation.html">UnitTestCase</a>.
+ This means that we can freely mix domain object testing with the
+ web interface...
+<pre>
+<strong>class TestOfRegistration extends UnitTestCase {
+ function testNewUserAddedToAuthenticator() {</strong>
+ $browser = &amp;new SimpleBrowser();
+ $browser-&gt;get('http://my-site.com/register.php');
+ $browser-&gt;setField('email', 'me@here');
+ $browser-&gt;setField('password', 'Secret');
+ $browser-&gt;click('Register');
+ <strong>
+ $authenticator = &amp;new Authenticator();
+ $member = &amp;$authenticator-&gt;findByEmail('me@here');
+ $this-&gt;assertEqual($member-&gt;getPassword(), 'Secret');
+ }
+}</strong>
+</pre>
+ While this may be a useful temporary expediency, I am not a fan
+ of this type of testing.
+ The testing has cut across application layers, make it twice as
+ likely it will need refactoring when the code changes.
+ </p>
+ <p>
+ A more useful case of where using the browser directly can be helpful
+ is where the <span class="new_code">WebTestCase</span> cannot cope.
+ An example is where two browsers are needed at the same time.
+ </p>
+ <p>
+ For example, say we want to disallow multiple simultaneous
+ usage of a site with the same username.
+ This test case will do the job...
+<pre>
+class TestOfSecurity extends UnitTestCase {
+ function testNoMultipleLoginsFromSameUser() {<strong>
+ $first = &amp;new SimpleBrowser();
+ $first-&gt;get('http://my-site.com/login.php');
+ $first-&gt;setField('name', 'Me');
+ $first-&gt;setField('password', 'Secret');
+ $first-&gt;click('Enter');
+ $this-&gt;assertEqual($first-&gt;getTitle(), 'Welcome');
+
+ $second = &amp;new SimpleBrowser();
+ $second-&gt;get('http://my-site.com/login.php');
+ $second-&gt;setField('name', 'Me');
+ $second-&gt;setField('password', 'Secret');
+ $second-&gt;click('Enter');
+ $this-&gt;assertEqual($second-&gt;getTitle(), 'Access Denied');</strong>
+ }
+}
+</pre>
+ You can also use the <span class="new_code">SimpleBrowser</span> class
+ directly when you want to write test cases using a different
+ test tool than SimpleTest.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
+ gives full detail on the classes and assertions available.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <span class="chosen">Scriptable browser</span>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/docs.css b/vendors/simpletest/docs/en/docs.css
new file mode 100644
index 000000000..18368a04f
--- /dev/null
+++ b/vendors/simpletest/docs/en/docs.css
@@ -0,0 +1,121 @@
+body {
+ padding-left: 3%;
+ padding-right: 3%;
+}
+h1, h2, h3 {
+ font-family: sans-serif;
+}
+h1 {
+ text-align: center;
+}
+pre {
+ font-family: "courier new", courier, typewriter, monospace;
+ font-size: 90%;
+ border: 1px solid;
+ border-color: #999966;
+ background-color: #ffffcc;
+ padding: 5px;
+ margin-left: 20px;
+ margin-right: 40px;
+}
+.code, .new_code, pre.new_code {
+ font-family: "courier new", courier, typewriter, monospace;
+ font-weight: bold;
+}
+div.copyright {
+ font-size: 80%;
+ color: gray;
+}
+div.copyright a {
+ margin-top: 1em;
+ color: gray;
+}
+ul.api {
+ border: 2px outset;
+ border-color: gray;
+ background-color: white;
+ margin: 5px;
+ margin-left: 5%;
+ margin-right: 5%;
+}
+ul.api li {
+ margin-top: 0.2em;
+ margin-bottom: 0.2em;
+ list-style: none;
+ text-indent: -3em;
+ padding-left: 1em;
+}
+div.demo {
+ border: 4px ridge;
+ border-color: gray;
+ padding: 10px;
+ margin: 5px;
+ margin-left: 20px;
+ margin-right: 40px;
+ background-color: white;
+}
+div.demo span.fail {
+ color: red;
+}
+div.demo span.pass {
+ color: green;
+}
+div.demo h1 {
+ font-size: 12pt;
+ text-align: left;
+ font-weight: bold;
+}
+div.menu {
+ text-align: center;
+}
+table {
+ border: 2px outset;
+ border-color: gray;
+ background-color: white;
+ margin: 5px;
+ margin-left: 5%;
+ margin-right: 5%;
+}
+td {
+ font-size: 90%;
+}
+.shell {
+ color: white;
+}
+pre.shell {
+ border: 4px ridge;
+ border-color: gray;
+ padding: 10px;
+ margin: 5px;
+ margin-left: 20px;
+ margin-right: 40px;
+ background-color: #000100;
+ color: #99ff99;
+ font-size: 90%;
+}
+pre.file {
+ color: black;
+ border: 1px solid;
+ border-color: black;
+ padding: 10px;
+ margin: 5px;
+ margin-left: 20px;
+ margin-right: 40px;
+ background-color: white;
+ font-size: 90%;
+}
+form.demo {
+ background-color: lightgray;
+ border: 4px outset;
+ border-color: lightgray;
+ padding: 10px;
+ margin-right: 40%;
+}
+dl, dd {
+ margin: 10px;
+ margin-left: 30px;
+}
+em {
+ font-weight: bold;
+ font-family: "courier new", courier, typewriter, monospace;
+}
diff --git a/vendors/simpletest/docs/en/expectation_documentation.html b/vendors/simpletest/docs/en/expectation_documentation.html
new file mode 100644
index 000000000..c3c959c4c
--- /dev/null
+++ b/vendors/simpletest/docs/en/expectation_documentation.html
@@ -0,0 +1,422 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>
+ Extending the SimpleTest unit tester with additional expectation classes
+ </title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <span class="chosen">Expectations</span>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Expectation documentation</h1>
+ This page...
+ <ul>
+<li>
+ Using expectations for
+ <a href="#mock">more precise testing with mock objects</a>
+ </li>
+<li>
+ <a href="#behaviour">Changing mock object behaviour</a> with expectations
+ </li>
+<li>
+ <a href="#extending">Extending the expectations</a>
+ </li>
+<li>
+ Underneath SimpleTest <a href="#unit">uses expectation classes</a>
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="mock"><h2>More control over mock objects</h2></a></p>
+ <p>
+ The default behaviour of the
+ <a href="mock_objects_documentation.html">mock objects</a>
+ in
+ <a href="http://sourceforge.net/projects/simpletest/">SimpleTest</a>
+ is either an identical match on the argument or to allow any argument at all.
+ For almost all tests this is sufficient.
+ Sometimes, though, you want to weaken a test case.
+ </p>
+ <p>
+ One place where a test can be too tightly coupled is with
+ text matching.
+ Suppose we have a component that outputs a helpful error
+ message when something goes wrong.
+ You want to test that the correct error was sent, but the actual
+ text may be rather long.
+ If you test for the text exactly, then every time the exact wording
+ of the message changes, you will have to go back and edit the test suite.
+ </p>
+ <p>
+ For example, suppose we have a news service that has failed
+ to connect to its remote source.
+<pre>
+<strong>class NewsService {
+ ...
+ function publish(&amp;$writer) {
+ if (! $this-&gt;isConnected()) {
+ $writer-&gt;write('Cannot connect to news service "' .
+ $this-&gt;_name . '" at this time. ' .
+ 'Please try again later.');
+ }
+ ...
+ }
+}</strong>
+</pre>
+ Here it is sending its content to a
+ <span class="new_code">Writer</span> class.
+ We could test this behaviour with a
+ <span class="new_code">MockWriter</span> like so...
+<pre>
+class TestOfNewsService extends UnitTestCase {
+ ...
+ function testConnectionFailure() {<strong>
+ $writer = &amp;new MockWriter();
+ $writer-&gt;expectOnce('write', array(
+ 'Cannot connect to news service ' .
+ '"BBC News" at this time. ' .
+ 'Please try again later.'));
+
+ $service = &amp;new NewsService('BBC News');
+ $service-&gt;publish($writer);</strong>
+ }
+}
+</pre>
+ This is a good example of a brittle test.
+ If we decide to add additional instructions, such as
+ suggesting an alternative news source, we will break
+ our tests even though no underlying functionality
+ has been altered.
+ </p>
+ <p>
+ To get around this, we would like to do a regular expression
+ test rather than an exact match.
+ We can actually do this with...
+<pre>
+class TestOfNewsService extends UnitTestCase {
+ ...
+ function testConnectionFailure() {
+ $writer = &amp;new MockWriter();<strong>
+ $writer-&gt;expectOnce(
+ 'write',
+ array(new PatternExpectation('/cannot connect/i')));</strong>
+
+ $service = &amp;new NewsService('BBC News');
+ $service-&gt;publish($writer);
+ }
+}
+</pre>
+ Instead of passing in the expected parameter to the
+ <span class="new_code">MockWriter</span> we pass an
+ expectation class called
+ <span class="new_code">WantedPatternExpectation</span>.
+ The mock object is smart enough to recognise this as special
+ and to treat it differently.
+ Rather than simply comparing the incoming argument to this
+ object, it uses the expectation object itself to
+ perform the test.
+ </p>
+ <p>
+ The <span class="new_code">WantedPatternExpectation</span> takes
+ the regular expression to match in its constructor.
+ Whenever a comparison is made by the <span class="new_code">MockWriter</span>
+ against this expectation class, it will do a
+ <span class="new_code">preg_match()</span> with this pattern.
+ With our test case above, as long as "cannot connect"
+ appears in the text of the string, the mock will issue a pass
+ to the unit tester.
+ The rest of the text does not matter.
+ </p>
+ <p>
+ The possible expectation classes are...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">AnythingExpectation</span></td>
+<td>Will always match</td>
+</tr>
+ <tr>
+<td><span class="new_code">EqualExpectation</span></td>
+<td>An equality, rather than the stronger identity comparison</td>
+</tr>
+ <tr>
+<td><span class="new_code">NotEqualExpectation</span></td>
+<td>An inequality comparison</td>
+</tr>
+ <tr>
+<td><span class="new_code">IndenticalExpectation</span></td>
+<td>The default mock object check which must match exactly</td>
+</tr>
+ <tr>
+<td><span class="new_code">NotIndenticalExpectation</span></td>
+<td>Inverts the mock object logic</td>
+</tr>
+ <tr>
+<td><span class="new_code">WithinMarginExpectation</span></td>
+<td>Compares a value to within a margin</td>
+</tr>
+ <tr>
+<td><span class="new_code">OutsideMarginExpectation</span></td>
+<td>Checks that a value is out side the margin</td>
+</tr>
+ <tr>
+<td><span class="new_code">PatternExpectation</span></td>
+<td>Uses a Perl Regex to match a string</td>
+</tr>
+ <tr>
+<td><span class="new_code">NoPatternExpectation</span></td>
+<td>Passes only if failing a Perl Regex</td>
+</tr>
+ <tr>
+<td><span class="new_code">IsAExpectation</span></td>
+<td>Checks the type or class name only</td>
+</tr>
+ <tr>
+<td><span class="new_code">NotAExpectation</span></td>
+<td>Opposite of the <span class="new_code">IsAExpectation</span>
+</td>
+</tr>
+ <tr>
+<td><span class="new_code">MethodExistsExpectation</span></td>
+<td>Checks a method is available on an object</td>
+</tr>
+ </tbody></table>
+ Most take the expected value in the constructor.
+ The exceptions are the pattern matchers, which take a regular expression,
+ and the <span class="new_code">IsAExpectation</span> and <span class="new_code">NotAExpectation</span> which takes a type
+ or class name as a string.
+ </p>
+ <p>
+ Some examples...
+ </p>
+ <p>
+<pre>
+$mock-&gt;expectOnce('method', array(new IdenticalExpectation(14)));
+</pre>
+ This is the same as <span class="new_code">$mock-&gt;expectOnce('method', array(14))</span>.
+<pre>
+$mock-&gt;expectOnce('method', array(new EqualExpectation(14)));
+</pre>
+ This is different from the previous version in that the string
+ <span class="new_code">"14"</span> as a parameter will also pass.
+ Sometimes the additional type checks of SimpleTest are too restrictive.
+<pre>
+$mock-&gt;expectOnce('method', array(new AnythingExpectation(14)));
+</pre>
+ This is the same as <span class="new_code">$mock-&gt;expectOnce('method', array('*'))</span>.
+<pre>
+$mock-&gt;expectOnce('method', array(new IdenticalExpectation('*')));
+</pre>
+ This is handy if you want to assert a literal <span class="new_code">"*"</span>.
+<pre>
+new NotIdenticalExpectation(14)
+</pre>
+ This matches on anything other than integer 14.
+ Even the string <span class="new_code">"14"</span> would pass.
+<pre>
+new WithinMarginExpectation(14.0, 0.001)
+</pre>
+ This will accept any value from 13.999 to 14.001 inclusive.
+ </p>
+
+ <p><a class="target" name="behaviour"><h2>Using expectations to control stubs</h2></a></p>
+ <p>
+ The expectation classes can be used not just for sending assertions
+ from mock objects, but also for selecting behaviour for the
+ <a href="mock_objects_documentation.html">mock objects</a>.
+ Anywhere a list of arguments is given, a list of expectation objects
+ can be inserted instead.
+ </p>
+ <p>
+ Suppose we want a mock authorisation server to simulate a successful login,
+ but only if it receives a valid session object.
+ We can do this as follows...
+<pre>
+Mock::generate('Authorisation');
+<strong>
+$authorisation = new MockAuthorisation();
+$authorisation-&gt;setReturnValue(
+ 'isAllowed',
+ true,
+ array(new IsAExpectation('Session', 'Must be a session')));
+$authorisation-&gt;setReturnValue('isAllowed', false);</strong>
+</pre>
+ We have set the default mock behaviour to return false when
+ <span class="new_code">isAllowed</span> is called.
+ When we call the method with a single parameter that
+ is a <span class="new_code">Session</span> object, it will return true.
+ We have also added a second parameter as a message.
+ This will be displayed as part of the mock object
+ failure message if this expectation is the cause of
+ a failure.
+ </p>
+ <p>
+ This kind of sophistication is rarely useful, but is included for
+ completeness.
+ </p>
+
+ <p><a class="target" name="extending"><h2>Creating your own expectations</h2></a></p>
+ <p>
+ The expectation classes have a very simple structure.
+ So simple that it is easy to create your own versions for
+ commonly used test logic.
+ </p>
+ <p>
+ As an example here is the creation of a class to test for
+ valid IP addresses.
+ In order to work correctly with the stubs and mocks the new
+ expectation class should extend
+ <span class="new_code">SimpleExpectation</span>...
+<pre>
+<strong>class ValidIp extends SimpleExpectation {
+
+ function test($ip) {
+ return (ip2long($ip) != -1);
+ }
+
+ function testMessage($ip) {
+ return "Address [$ip] should be a valid IP address";
+ }
+}</strong>
+</pre>
+ There are only two methods to implement.
+ The <span class="new_code">test()</span> method should
+ evaluate to true if the expectation is to pass, and
+ false otherwise.
+ The <span class="new_code">testMessage()</span> method
+ should simply return some helpful text explaining the test
+ that was carried out.
+ </p>
+ <p>
+ This class can now be used in place of the earlier expectation
+ classes.
+ </p>
+
+ <p><a class="target" name="unit"><h2>Under the bonnet of the unit tester</h2></a></p>
+ <p>
+ The <a href="http://sourceforge.net/projects/simpletest/">SimpleTest unit testing framework</a>
+ also uses the expectation classes internally for the
+ <a href="unit_test_documentation.html">UnitTestCase class</a>.
+ We can also take advantage of these mechanisms to reuse our
+ homebrew expectation classes within the test suites directly.
+ </p>
+ <p>
+ The most crude way of doing this is to use the
+ <span class="new_code">SimpleTest::assert()</span> method to
+ test against it directly...
+<pre>
+<strong>class TestOfNetworking extends UnitTestCase {
+ ...
+ function testGetValidIp() {
+ $server = &amp;new Server();
+ $this-&gt;assert(
+ new ValidIp(),
+ $server-&gt;getIp(),
+ 'Server IP address-&gt;%s');
+ }
+}</strong>
+</pre>
+ This is a little untidy compared with our usual
+ <span class="new_code">assert...()</span> syntax.
+ </p>
+ <p>
+ For such a simple case we would normally create a
+ separate assertion method on our test case rather
+ than bother using the expectation class.
+ If we pretend that our expectation is a little more
+ complicated for a moment, so that we want to reuse it,
+ we get...
+<pre>
+class TestOfNetworking extends UnitTestCase {
+ ...<strong>
+ function assertValidIp($ip, $message = '%s') {
+ $this-&gt;assert(new ValidIp(), $ip, $message);
+ }</strong>
+
+ function testGetValidIp() {
+ $server = &amp;new Server();<strong>
+ $this-&gt;assertValidIp(
+ $server-&gt;getIp(),
+ 'Server IP address-&gt;%s');</strong>
+ }
+}
+</pre>
+ It is unlikely we would ever need this degree of control
+ over the testing machinery.
+ It is rare to need the expectations for more than pattern
+ matching.
+ Also, complex expectation classes could make the tests
+ harder to read and debug.
+ These mechanisms are really of most use to authors of systems
+ that will extend the test framework to create their own tool set.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ The expectations mimic the constraints in <a href="http://www.jmock.org/">JMock</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">Full API for SimpleTest</a>
+ from the PHPDoc.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <span class="chosen">Expectations</span>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/form_testing_documentation.html b/vendors/simpletest/docs/en/form_testing_documentation.html
new file mode 100644
index 000000000..fe0fcccf0
--- /dev/null
+++ b/vendors/simpletest/docs/en/form_testing_documentation.html
@@ -0,0 +1,342 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Simple Test documentation for testing HTML forms</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <span class="chosen">Testing forms</span>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Form testing documentation</h1>
+ This page...
+ <ul>
+<li>
+ Changing form values and successfully
+ <a href="#submit">Submitting a simple form</a>
+ </li>
+<li>
+ Handling <a href="#multiple">widgets with multiple values</a>
+ by setting lists.
+ </li>
+<li>
+ Bypassing javascript to <a href="#hidden-field">set a hidden field</a>.
+ </li>
+<li>
+ <a href="#raw">Raw posting</a> when you don't have a button
+ to click.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="submit"><h2>Submitting a simple form</h2></a></p>
+ <p>
+ When a page is fetched by the <span class="new_code">WebTestCase</span>
+ using <span class="new_code">get()</span> or
+ <span class="new_code">post()</span> the page content is
+ automatically parsed.
+ This results in any form controls that are inside &lt;form&gt; tags
+ being available from within the test case.
+ For example, if we have this snippet of HTML...
+<pre>
+&lt;form&gt;
+ &lt;input type="text" name="a" value="A default" /&gt;
+ &lt;input type="submit" value="Go" /&gt;
+&lt;/form&gt;
+</pre>
+ Which looks like this...
+ </p>
+ <p>
+ <form class="demo">
+ <input type="text" name="a" value="A default">
+ <input type="submit" value="Go">
+ </form>
+ </p>
+ <p>
+ We can navigate to this code, via the
+ <a href="http://www.lastcraft.com/form_testing_documentation.php">LastCraft</a>
+ site, with the following test...
+<pre>
+class SimpleFormTests extends WebTestCase {
+ <strong>
+ function testDefaultValue() {
+ $this-&gt;get('http://www.lastcraft.com/form_testing_documentation.php');
+ $this-&gt;assertField('a', 'A default');
+ }</strong>
+}
+</pre>
+ Immediately after loading the page all of the HTML controls are set at
+ their default values just as they would appear in the web browser.
+ The assertion tests that a HTML widget exists in the page with the
+ name "a" and that it is currently set to the value
+ "A default".
+ As usual, we could use a pattern expectation instead if a fixed
+ string.
+ </p>
+ <p>
+ We could submit the form straight away, but first we'll change
+ the value of the text field and only then submit it...
+<pre>
+class SimpleFormTests extends WebTestCase {
+
+ function testDefaultValue() {
+ $this-&gt;get('http://www.my-site.com/');
+ $this-&gt;assertField('a', 'A default');<strong>
+ $this-&gt;setField('a', 'New value');
+ $this-&gt;click('Go');</strong>
+ }
+}
+</pre>
+ Because we didn't specify a method attribute on the form tag, and
+ didn't specify an action either, the test case will follow
+ the usual browser behaviour of submitting the form data as a <em>GET</em>
+ request back to the same location.
+ SimpleTest tries to emulate typical browser behaviour as much as possible,
+ rather than attempting to catch missing attributes on tags.
+ This is because the target of the testing framework is the PHP application
+ logic, not syntax or other errors in the HTML code.
+ For HTML errors, other tools such as
+ <a href="http://www.w3.org/People/Raggett/tidy/">HTMLTidy</a> should be used.
+ </p>
+ <p>
+ If a field is not present in any form, or if an option is unavailable,
+ then <span class="new_code">WebTestCase::setField()</span> will return
+ <span class="new_code">false</span>.
+ For example, suppose we wish to verify that a "Superuser"
+ option is not present in this form...
+<pre>
+&lt;strong&gt;Select type of user to add:&lt;/strong&gt;
+&lt;select name="type"&gt;
+ &lt;option&gt;Subscriber&lt;/option&gt;
+ &lt;option&gt;Author&lt;/option&gt;
+ &lt;option&gt;Administrator&lt;/option&gt;
+&lt;/select&gt;
+</pre>
+ Which looks like...
+ </p>
+ <p>
+ <form class="demo">
+ <strong>Select type of user to add:</strong>
+ <select name="type">
+ <option>Subscriber</option>
+ <option>Author</option>
+ <option>Administrator</option>
+ </select>
+ </form>
+ </p>
+ <p>
+ The following test will confirm it...
+<pre>
+class SimpleFormTests extends WebTestCase {
+ ...
+ function testNoSuperuserChoiceAvailable() {<strong>
+ $this-&gt;get('http://www.lastcraft.com/form_testing_documentation.php');
+ $this-&gt;assertFalse($this-&gt;setField('type', 'Superuser'));</strong>
+ }
+}
+</pre>
+ The selection will not be changed on a failure to set
+ a widget value.
+ </p>
+ <p>
+ Here is the full list of widgets currently supported...
+ <ul>
+ <li>Text fields, including hidden and password fields.</li>
+ <li>Submit buttons including the button tag, although not yet reset buttons</li>
+ <li>Text area. This includes text wrapping behaviour.</li>
+ <li>Checkboxes, including multiple checkboxes in the same form.</li>
+ <li>Drop down selections, including multiple selects.</li>
+ <li>Radio buttons.</li>
+ <li>Images.</li>
+ </ul>
+ </p>
+ <p>
+ The browser emulation offered by SimpleTest mimics
+ the actions which can be perform by a user on a
+ standard HTML page. Javascript is not supported, and
+ it's unlikely that support will be added any time
+ soon.
+ </p>
+ <p>
+ Of particular note is that the Javascript idiom of
+ passing form results by setting a hidden field cannot
+ be performed using the normal SimpleTest
+ commands. See below for a way to test such forms.
+ </p>
+
+ <p><a class="target" name="multiple"><h2>Fields with multiple values</h2></a></p>
+ <p>
+ SimpleTest can cope with two types of multivalue controls: Multiple
+ selection drop downs, and multiple checkboxes with the same name
+ within a form.
+ The multivalue nature of these means that setting and testing
+ are slightly different.
+ Using checkboxes as an example...
+<pre>
+&lt;form class="demo"&gt;
+ &lt;strong&gt;Create privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="c" checked&gt;&lt;br&gt;
+ &lt;strong&gt;Retrieve privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="r" checked&gt;&lt;br&gt;
+ &lt;strong&gt;Update privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="u" checked&gt;&lt;br&gt;
+ &lt;strong&gt;Destroy privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="d" checked&gt;&lt;br&gt;
+ &lt;input type="submit" value="Enable Privileges"&gt;
+&lt;/form&gt;
+</pre>
+ Which renders as...
+ </p>
+ <p>
+ <form class="demo">
+ <strong>Create privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="c" checked><br>
+ <strong>Retrieve privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="r" checked><br>
+ <strong>Update privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="u" checked><br>
+ <strong>Destroy privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="d" checked><br>
+ <input type="submit" value="Enable Privileges">
+ </form>
+ </p>
+ <p>
+ If we wish to disable all but the retrieval privileges and
+ submit this information we can do it like this...
+<pre>
+class SimpleFormTests extends WebTestCase {
+ ...<strong>
+ function testDisableNastyPrivileges() {
+ $this-&gt;get('http://www.lastcraft.com/form_testing_documentation.php');
+ $this-&gt;assertField('crud', array('c', 'r', 'u', 'd'));
+ $this-&gt;setField('crud', array('r'));
+ $this-&gt;click('Enable Privileges');
+ }</strong>
+}
+</pre>
+ Instead of setting the field to a single value, we give it a list
+ of values.
+ We do the same when testing expected values.
+ We can then write other test code to confirm the effect of this, perhaps
+ by logging in as that user and attempting an update.
+ </p>
+
+ <p><a class="target" name="hidden-field"><h2>Forms which use javascript to set a hidden field</h2></a></p>
+ <p>
+ If you want to test a form which relies on javascript to set a hidden
+ field, you can't just call setField().
+ The following code will <em>not</em> work:
+<pre>
+class SimpleFormTests extends WebTestCase {
+ function testMyJavascriptForm() {
+ <strong>// This does *not* work</strong>
+ $this-&gt;setField('a_hidden_field', '123');
+ $this-&gt;clickSubmit('OK');
+ }
+}
+</pre>
+ Instead, you need to pass the additional form parameters to the
+ clickSubmit() method:
+<pre>
+class SimpleFormTests extends WebTestCase {
+ function testMyJavascriptForm() {
+ // Pass the hidden field value as an additional POST variable
+ <strong>$this-&gt;clickSubmit('OK', array('a_hidden_field'=&gt;'123'));</strong>
+ }
+
+}
+</pre>
+ </p>
+ <p>
+ Bear in mind that in doing this you're effectively stubbing out a
+ part of your software (the javascript code in the form), and
+ perhaps you might be better off using something like
+ <a href="http://selenium.openqa.org/">Selenium</a> to ensure a complete
+ acceptance test.
+ </p>
+
+ <p><a class="target" name="raw"><h2>Raw posting</h2></a></p>
+ <p>
+ If you want to test a form handler, but have not yet written
+ or do not have access to the form itself, you can create a
+ form submission by hand.
+<pre>
+class SimpleFormTests extends WebTestCase {
+ ...<strong>
+ function testAttemptedHack() {
+ $this-&gt;post(
+ 'http://www.my-site.com/add_user.php',
+ array('type' =&gt; 'superuser'));
+ $this-&gt;assertNoText('user created');
+ }</strong>
+}
+</pre>
+ By adding data to the <span class="new_code">WebTestCase::post()</span>
+ method, we are attempting to fetch the page as a form submission.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
+ gives full detail on the classes and assertions available.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <span class="chosen">Testing forms</span>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/group_test_documentation.html b/vendors/simpletest/docs/en/group_test_documentation.html
new file mode 100644
index 000000000..a0c78843c
--- /dev/null
+++ b/vendors/simpletest/docs/en/group_test_documentation.html
@@ -0,0 +1,386 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>SimpleTest for PHP test suites</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <span class="chosen">Group tests</span>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Test suite documentation</h1>
+ This page...
+ <ul>
+<li>
+ Different ways to <a href="#group">group tests</a> together.
+ </li>
+<li>
+ Combining group tests into <a href="#higher">larger groups</a>.
+ </li>
+<li>
+ Integrating <a href="#legacy">legacy test cases</a> from other
+ types of PHPUnit.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="group"><h2>Grouping tests into suites</h2></a></p>
+ <p>
+ To run test cases as part of a group, the test cases should really
+ be placed in files without the runner code...
+<pre>
+<strong>&lt;?php
+ require_once('../classes/io.php');
+
+ class FileTester extends UnitTestCase {
+ ...
+ }
+
+ class SocketTester extends UnitTestCase {
+ ...
+ }
+?&gt;</strong>
+</pre>
+ As many cases as needed can appear in a single file.
+ They should include any code they need, such as the library
+ being tested, but none of the simple test libraries.
+ </p>
+ <p>
+ If you have extended any test cases, you can include them
+ as well. In PHP 4...
+<pre>
+&lt;?php
+ require_once('../classes/io.php');
+<strong>
+ class MyFileTestCase extends UnitTestCase {
+ ...
+ }
+ SimpleTest::ignore('MyFileTestCase');</strong>
+
+ class FileTester extends MyFileTestCase { ... }
+
+ class SocketTester extends UnitTestCase { ... }
+?&gt;
+</pre>
+ The <span class="new_code">FileTester</span> class does
+ not contain any actual tests, but is a base class for other
+ test cases.
+ For this reason we use the
+ <span class="new_code">SimpleTestOptions::ignore()</span> directive
+ to tell the upcoming group test to ignore it.
+ This directive can appear anywhere in the file and works
+ when a whole file of test cases is loaded (see below).
+ </p>
+ <p>
+ If you are using PHP 5, you do not need this special directive at all.
+ Simply mark any test cases that should not be run as abstract...
+<pre>
+<strong>abstract</strong> class MyFileTestCase extends UnitTestCase {
+ ...
+}
+
+class FileTester extends MyFileTestCase { ... }
+
+class SocketTester extends UnitTestCase { ... }
+</pre>
+ </p>
+ <p>
+ We will call this sample <em>file_test.php</em>.
+ Next we create a group test file, called say <em>my_group_test.php</em>.
+ You will think of a better name I am sure.
+ </p>
+ <p>
+ We will add the test file using a safe method...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');<strong>
+ require_once('file_test.php');
+
+ $test = &amp;new TestSuite('All file tests');
+ $test-&gt;addTestCase(new FileTestCase());
+ $test-&gt;run(new HtmlReporter());</strong>
+?&gt;
+</pre>
+ This instantiates the test case before the test suite is
+ run.
+ This could get a little expensive with a large number of test
+ cases, and can be surprising behaviour.
+ </p>
+ <p>
+ The main problem is that for every test case
+ that we add we will have
+ to <span class="new_code">require_once()</span> the test code
+ file and manually instantiate each and every test case.
+ </p>
+ <p>
+ We can save a lot of typing with...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');
+
+ $test = &amp;new TestSuite('All file tests');<strong>
+ $test-&gt;addTestFile('file_test.php');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&amp;gt;
+</pre>
+ What happens here is that the <span class="new_code">TestSuite</span>
+ class has done the <span class="new_code">require_once()</span>
+ for us.
+ It then checks to see if any new test case classes
+ have been created by the new file and automatically adds
+ them to the group test.
+ Now all we have to do is add each new file.
+ </p>
+ <p>
+ No only that, but you can guarantee that the constructor is run
+ just before the first test method and, in PHP 5, the destructor
+ is run just after the last test method.
+ </p>
+ <p>
+ There are two things that could go wrong and which require care...
+ <ol>
+ <li>
+ The file could already have been parsed by PHP, and so no
+ new classes will have been added. You should make
+ sure that the test cases are only included in this file
+ and no others (Note : with the new <cite>autorun</cite>
+ functionnality, this problem has now been solved).
+ </li>
+ <li>
+ New test case extension classes that get included will be
+ placed in the group test and run also.
+ You will need to add a <span class="new_code">SimpleTestOptions::ignore()</span>
+ directive for these classes, or make sure that they are included
+ before the <span class="new_code">TestSuite::addTestFile()</span>
+ line, or make sure that they are abstract classes.
+ </li>
+ </ol>
+ </p>
+
+ <p><a class="target" name="higher"><h2>Composite suites</h2></a></p>
+ <p>
+ The above method places all of the test cases into one large group.
+ For larger projects though this may not be flexible enough; you
+ may want to group the tests in all sorts of ways.
+ </p>
+ <p>
+ To get a more flexible group test we can subclass
+ <span class="new_code">TestSuite</span> and then instantiate it as needed...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');
+ <strong>
+ class FileTestSuite extends TestSuite {
+ function FileTestSuite() {
+ $this-&gt;TestSuite('All file tests');
+ $this-&gt;addTestFile('file_test.php');
+ }
+ }</strong>
+?&gt;
+</pre>
+ This effectively names the test in the constructor and then
+ adds our test cases and a single group below.
+ Of course we can add more than one group at this point.
+ We can now invoke the tests from a separate runner file...
+<pre>
+&lt;?php
+ require_once('file_test_suite.php');
+ <strong>
+ $test = &amp;new FileTestSuite();
+ $test-&gt;run(new HtmlReporter());</strong>
+?&gt;
+</pre>
+ ...or we can group them into even larger group tests.
+ We can even mix groups and test cases freely as long as
+ we are careful about double includes...
+<pre>
+&lt;?php
+ <strong>
+ $test = &amp;new BigTestSuite('Big group');
+ $test-&gt;addTestFile('file_test_suite.php');
+ $test-&gt;addTestFile('some_test_case.php');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ In the event of a double include, ony the first instance
+ of the test case will be run.
+ </p>
+ <p>
+ If we still wish to run the original group test, and we
+ don't want all of these little runner files, we can
+ put the test runner code around guard bars when we create
+ each group.
+<pre>
+&lt;?php
+ class FileTestSuite extends TestSuite {
+ function FileTestSuite() {
+ $this-&gt;TestSuite('All file tests');
+ $test-&gt;addTestFile('file_test.php');
+ }
+ }
+ <strong>
+ if (! defined('RUNNER')) {
+ define('RUNNER', true);</strong>
+ $test = &amp;new FileTestSuite();
+ $test-&gt;run(new HtmlReporter());
+ }
+?&gt;
+</pre>
+ This approach requires the guard to be set when including
+ the group test file, but this is still less hassle than
+ lots of separate runner files.
+ You include the same guard on the top level tests to make sure
+ that <span class="new_code">run()</span> will run once only
+ from the top level script that has been invoked.
+<pre>
+&lt;?php<strong>
+ define('RUNNER', true);</strong>
+ require_once('file_test_suite.php');
+
+ $test = &amp;new BigTestSuite('Big group');
+ $test-&gt;addTestCase(new FileTestSuite());
+ $test-&gt;addTestCase(...);
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ As with the normal test cases, a <span class="new_code">TestSuite</span> can
+ be loaded with the <span class="new_code">TestSuite::addTestFile()</span> method.
+<pre>
+&lt;?php
+ define('RUNNER', true);
+
+ $test = &amp;new BigTestSuite('Big group');<strong>
+ $test-&gt;addTestFile('file_test_suite.php');
+ $test-&gt;addTestFile(...);</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ </p>
+
+ <p><a class="target" name="legacy"><h2>Integrating legacy test cases</h2></a></p>
+ <p>
+ If you already have unit tests for your code or are extending external
+ classes that have tests, it is unlikely that all of the test cases
+ are in SimpleTest format.
+ Fortunately it is possible to incorporate test cases from other
+ unit testers directly into SimpleTest group tests.
+ </p>
+ <p>
+ Say we have the following
+ <a href="http://sourceforge.net/projects/phpunit">PhpUnit</a>
+ test case in the file <em>config_test.php</em>...
+<pre>
+<strong>class ConfigFileTest extends TestCase {
+ function ConfigFileTest() {
+ $this-&gt;TestCase('Config file test');
+ }
+
+ function testContents() {
+ $config = new ConfigFile('test.conf');
+ $this-&gt;assertRegexp('/me/', $config-&gt;getValue('username'));
+ }
+}</strong>
+</pre>
+ The group test can recognise this as long as we include
+ the appropriate adapter class before we add the test
+ file...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');<strong>
+ require_once('simpletest/adapters/phpunit_test_case.php');</strong>
+
+ $test = &amp;new TestSuite('All file tests');<strong>
+ $test-&gt;addTestFile('config_test.php');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ There are only two adapters, the other is for the
+ <a href="http://pear.php.net/manual/en/package.php.phpunit.php">PEAR</a>
+ 1.0 unit tester...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');<strong>
+ require_once('simpletest/adapters/pear_test_case.php');</strong>
+
+ $test = &amp;new TestSuite('All file tests');<strong>
+ $test-&gt;addTestFile('some_pear_test_cases.php');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ The PEAR test cases can be freely mixed with SimpleTest
+ ones even in the same test file,
+ but you cannot use SimpleTest assertions in the legacy
+ test case versions.
+ This is done as a check that you are not accidently making
+ your test cases completely dependent on SimpleTest.
+ You may want to do a PEAR release of your library for example,
+ which would mean shipping it with valid PEAR::PhpUnit test
+ cases.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <span class="chosen">Group tests</span>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/index.html b/vendors/simpletest/docs/en/index.html
new file mode 100644
index 000000000..03b6c5cef
--- /dev/null
+++ b/vendors/simpletest/docs/en/index.html
@@ -0,0 +1,538 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>
+ Download the Simple Test testing framework -
+ Unit tests and mock objects for PHP
+ </title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<span class="chosen">SimpleTest</span>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Simple Test for PHP</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#unit">Using unit tester</a>
+ with an example.
+ </li>
+<li>
+ <a href="#group">Grouping tests</a>
+ for testing with one click.
+ </li>
+<li>
+ <a href="#mock">Using mock objects</a>
+ to ease testing and gain tighter control.
+ </li>
+<li>
+ <a href="#web">Testing web pages</a>
+ at the browser level.
+ </li>
+</ul>
+<div class="content">
+
+
+ <p>
+ The following assumes that you are familiar with the concept
+ of unit testing as well as the PHP web development language.
+ It is a guide for the impatient new user of
+ <a href="https://sourceforge.net/project/showfiles.php?group_id=76550">SimpleTest</a>.
+ For fuller documentation, especially if you are new
+ to unit testing see the ongoing
+ <a href="unit_test_documentation.html">documentation</a>, and for
+ example test cases see the
+ <a href="http://www.lastcraft.com/first_test_tutorial.php">unit testing tutorial</a>.
+ </p>
+
+ <p><a class="target" name="unit"><h2>Using the tester quickly</h2></a></p>
+ <p>
+ Amongst software testing tools, a unit tester is the one
+ closest to the developer.
+ In the context of agile development the test code sits right
+ next to the source code as both are written simultaneously.
+ In this context SimpleTest aims to be a complete PHP developer
+ test solution and is called "Simple" because it
+ should be easy to use and extend.
+ It wasn't a good choice of name really.
+ It includes all of the typical functions you would expect from
+ <a href="http://www.junit.org/">JUnit</a> and the
+ <a href="http://sourceforge.net/projects/phpunit/">PHPUnit</a>
+ ports, and includes
+ <a href="http://www.mockobjects.com">mock objects</a>.
+ </p>
+ <p>
+ What makes this tool immediately useful to the PHP developer is the internal
+ web browser.
+ This allows tests that navigate web sites, fill in forms and test pages.
+ Being able to write these test in PHP means that it is easy to write
+ integrated tests.
+ An example might be confirming that a user was written to a database
+ after a signing up through the web site.
+ </p>
+ <p>
+ The quickest way to demonstrate SimpleTest is with an example.
+ </p>
+ <p>
+ Let us suppose we are testing a simple file logging class called
+ <span class="new_code">Log</span> in <em>classes/log.php</em>.
+ We start by creating a test script which we will call
+ <em>tests/log_test.php</em> and populate it as follows...
+<pre>
+&lt;?php
+<strong>require_once('simpletest/autorun.php');</strong>
+require_once('../classes/log.php');
+
+class TestOfLogging extends <strong>UnitTestCase</strong> {
+}
+?&gt;
+</pre>
+ Here the <em>simpletest</em> folder is either local or in the path.
+ You would have to edit these locations depending on where you
+ unpacked the toolset.
+ The "autorun.php" file does more than just include the
+ SimpleTest files, it also runs our test for us.
+ </p>
+ <p>
+ The <span class="new_code">TestOfLogging</span> is our first test case and it's
+ currently empty.
+ Each test case is a class that extends one of the SimpleTet base classes
+ and we can have as many of these in the file as we want.
+ </p>
+ <p>
+ With three lines of scaffolding, and our <span class="new_code">Log</span> class
+ include, we have a test suite.
+ No tests though.
+ </p>
+ <p>
+ For our first test, we'll assume that the <span class="new_code">Log</span> class
+ takes the file name to write to in the constructor, and we have
+ a temporary folder in which to place this file...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('../classes/log.php');
+
+class TestOfLogging extends UnitTestCase {
+ function <strong>testLogCreatesNewFileOnFirstMessage()</strong> {
+ @unlink('/temp/test.log');
+ $log = new Log('/temp/test.log');
+ <strong>$this-&gt;assertFalse(file_exists('/temp/test.log'));</strong>
+ $log-&gt;message('Should write this to a file');
+ <strong>$this-&gt;assertTrue(file_exists('/temp/test.log'));</strong>
+ }
+}
+?&gt;
+</pre>
+ When a test case runs, it will search for any method that
+ starts with the string "test"
+ and execute that method.
+ If the method starts "test", it's a test.
+ Note the very long name <span class="new_code">testLogCreatesNewFileOnFirstMessage()</span>.
+ This is considered good style and makes the test output more readable.
+ </p>
+ <p>
+ We would normally have more than one test method in a test case,
+ but that's for later.
+ </p>
+ <p>
+ Assertions within the test methods trigger messages to the
+ test framework which displays the result immediately.
+ This immediate response is important, not just in the event
+ of the code causing a crash, but also so that
+ <span class="new_code">print</span> statements can display
+ their debugging content right next to the assertion concerned.
+ </p>
+ <p>
+ To see these results we have to actually run the tests.
+ No other code is necessary - we can just open the page
+ with our browser.
+ </p>
+ <p>
+ On failure the display looks like this...
+ <div class="demo">
+ <h1>TestOfLogging</h1>
+ <span class="fail">Fail</span>: testLogCreatesNewFileOnFirstMessage-&gt;True assertion failed.<br>
+ <div style="padding: 8px; margin-top: 1em; background-color: red; color: white;">1/1 test cases complete.
+ <strong>1</strong> passes and <strong>1</strong> fails.</div>
+ </div>
+ ...and if it passes like this...
+ <div class="demo">
+ <h1>TestOfLogging</h1>
+ <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">1/1 test cases complete.
+ <strong>2</strong> passes and <strong>0</strong> fails.</div>
+ </div>
+ And if you get this...
+ <div class="demo">
+ <b>Fatal error</b>: Failed opening required '../classes/log.php' (include_path='') in <b>/home/marcus/projects/lastcraft/tutorial_tests/Log/tests/log_test.php</b> on line <b>7</b>
+ </div>
+ it means you're missing the <em>classes/Log.php</em> file that could look like...
+<pre>
+&lt;?php<strong>
+class Log {
+ function Log($file_path) {
+ }
+
+ function message() {
+ }
+}</strong>
+?&gt;
+</pre>
+ It's fun to write the code after the test.
+ More than fun even -
+ this system is called "Test Driven Development".
+ </p>
+ <p>
+ For more information about <span class="new_code">UnitTestCase</span>, see
+ the <a href="unit_test_documentation.html">unit test documentation</a>.
+ </p>
+
+ <p><a class="target" name="group"><h2>Building test suites</h2></a></p>
+ <p>
+ It is unlikely in a real application that we will only ever run
+ one test case.
+ This means that we need a way of grouping cases into a test
+ script that can, if need be, run every test for the application.
+ </p>
+ <p>
+ Our first step is to create a new file called <em>tests/all_tests.php</em>
+ and insert the following code...
+<pre>
+&lt;?php
+<strong>require_once('simpletest/autorun.php');</strong>
+
+class AllTests extends <strong>TestSuite</strong> {
+ function AllTests() {
+ $this-&gt;TestSuite(<strong>'All tests'</strong>);
+ <strong>$this-&gt;addFile('log_test.php');</strong>
+ }
+}
+?&gt;
+</pre>
+ The "autorun" include allows our upcoming test suite
+ to be run just by invoking this script.
+ </p>
+ <p>
+ The <span class="new_code">TestSuite</span> subclass must chain it's constructor.
+ This limitation will be removed in future versions.
+ </p>
+ <p>
+ The method <span class="new_code">TestSuite::addFile()</span>
+ will include the test case file and read any new classes
+ that are descended from <span class="new_code">SimpleTestCase</span>.
+ <span class="new_code">UnitTestCase</span> is just one example of a class derived from
+ <span class="new_code">SimpleTestCase</span>, and you can create your own.
+ <span class="new_code">TestSuite::addFile()</span> can include other test suites.
+ </p>
+ <p>
+ The class will not be instantiated yet.
+ When the test suite runs it will construct each instance once
+ it reaches that test, then destroy it straight after.
+ This means that the constructor is run just before each run
+ of that test case, and the destructor is run before the next test case starts.
+ </p>
+ <p>
+ It is common to group test case code into superclasses which are not
+ supposed to run, but become the base classes of other tests.
+ For "autorun" to work properly the test case file should not blindly run
+ any other test case extensions that do not actually run tests.
+ This could result in extra test cases being counted during the test
+ run.
+ Hardly a major problem, but to avoid this inconvenience simply mark your
+ base class as <span class="new_code">abstract</span>.
+ SimpleTest won't run abstract classes.
+ If you are still using PHP4, then
+ a <span class="new_code">SimpleTestOptions::ignore()</span> directive
+ somewhere in the test case file will have the same effect.
+ </p>
+ <p>
+ Also, the test case file should not have been included
+ elsewhere or no cases will be added to this group test.
+ This would be a more serious error as if the test case classes are
+ already loaded by PHP the <span class="new_code">TestSuite::addFile()</span>
+ method will not detect them.
+ </p>
+ <p>
+ To display the results it is necessary only to invoke
+ <em>tests/all_tests.php</em> from the web server or the command line.
+ </p>
+ <p>
+ For more information about building test suites,
+ see the <a href="group_test_documentation.html">test suite documentation</a>.
+ </p>
+
+ <p><a class="target" name="mock"><h2>Using mock objects</h2></a></p>
+ <p>
+ Let's move further into the future and do something really complicated.
+ </p>
+ <p>
+ Assume that our logging class is tested and completed.
+ Assume also that we are testing another class that is
+ required to write log messages, say a
+ <span class="new_code">SessionPool</span>.
+ We want to test a method that will probably end up looking
+ like this...
+<pre><strong>
+class SessionPool {
+ ...
+ function logIn($username) {
+ ...
+ $this-&gt;_log-&gt;message("User $username logged in.");
+ ...
+ }
+ ...
+}
+</strong>
+</pre>
+ In the spirit of reuse, we are using our
+ <span class="new_code">Log</span> class.
+ A conventional test case might look like this...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('../classes/log.php');
+<strong>require_once('../classes/session_pool.php');</strong>
+
+class <strong>TestOfSessionLogging</strong> extends UnitTestCase {
+
+ function setUp() {
+ <strong>@unlink('/temp/test.log');</strong>
+ }
+
+ function tearDown() {
+ <strong>@unlink('/temp/test.log');</strong>
+ }
+
+ function testLoggingInIsLogged() {
+ <strong>$log = new Log('/temp/test.log');
+ $session_pool = &amp;new SessionPool($log);
+ $session_pool-&gt;logIn('fred');</strong>
+ $messages = file('/temp/test.log');
+ $this-&gt;assertEqual($messages[0], "User fred logged in.<strong>\n</strong>");
+ }
+}
+?&gt;
+</pre>
+ We'll explain the <span class="new_code">setUp()</span> and <span class="new_code">tearDown()</span>
+ methods later.
+ </p>
+ <p>
+ This test case design is not all bad, but it could be improved.
+ We are spending time fiddling with log files which are
+ not part of our test.
+ We have created close ties with the <span class="new_code">Log</span> class and
+ this test.
+ What if we don't use files any more, but use ths
+ <em>syslog</em> library instead?
+ It means that our <span class="new_code">TestOfSessionLogging</span> test will
+ fail, even thouh it's not testing Logging.
+ </p>
+ <p>
+ It's fragile in smaller ways too.
+ Did you notice the extra carriage return in the message?
+ Was that added by the logger?
+ What if it also added a time stamp or other data?
+ </p>
+ <p>
+ The only part that we really want to test is that a particular
+ message was sent to the logger.
+ We can reduce coupling if we pass in a fake logging class
+ that simply records the message calls for testing, but
+ takes no action.
+ It would have to look exactly like our original though.
+ </p>
+ <p>
+ If the fake object doesn't write to a file then we save on deleting
+ the file before and after each test. We could save even more
+ test code if the fake object would kindly run the assertion for us.
+ <p>
+ </p>
+ Too good to be true?
+ We can create such an object easily...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('../classes/log.php');
+require_once('../classes/session_pool.php');
+
+<strong>Mock::generate('Log');</strong>
+
+class TestOfSessionLogging extends UnitTestCase {
+
+ function testLoggingInIsLogged() {<strong>
+ $log = &amp;new MockLog();
+ $log-&gt;expectOnce('message', array('User fred logged in.'));</strong>
+ $session_pool = &amp;new SessionPool(<strong>$log</strong>);
+ $session_pool-&gt;logIn('fred');
+ }
+}
+?&gt;
+</pre>
+ The <span class="new_code">Mock::generate()</span> call code generated a new class
+ called <span class="new_code">MockLog</span>.
+ This looks like an identical clone, except that we can wire test code
+ to it.
+ That's what <span class="new_code">expectOnce()</span> does.
+ It says that if <span class="new_code">message()</span> is ever called on me, it had
+ better be with the parameter "User fred logged in.".
+ </p>
+ <p>
+ The test will be triggered when the call to
+ <span class="new_code">message()</span> is invoked on the
+ <span class="new_code">MockLog</span> object by <span class="new_code">SessionPool::logIn()</span> code.
+ The mock call will trigger a parameter comparison and then send the
+ resulting pass or fail event to the test display.
+ Wildcards can be included here too, so you don't have to test every parameter of
+ a call when you only want to test one.
+ </p>
+ <p>
+ If the mock reaches the end of the test case without the
+ method being called, the <span class="new_code">expectOnce()</span>
+ expectation will trigger a test failure.
+ In other words the mocks can detect the absence of
+ behaviour as well as the presence.
+ </p>
+ <p>
+ The mock objects in the SimpleTest suite can have arbitrary
+ return values set, sequences of returns, return values
+ selected according to the incoming arguments, sequences of
+ parameter expectations and limits on the number of times
+ a method is to be invoked.
+ </p>
+ <p>
+ For more information about mocking and stubbing, see the
+ <a href="mock_objects_documentation.html">mock objects documentation</a>.
+ </p>
+
+ <p><a class="target" name="web"><h2>Web page testing</h2></a></p>
+ <p>
+ One of the requirements of web sites is that they produce web
+ pages.
+ If you are building a project top-down and you want to fully
+ integrate testing along the way then you will want a way of
+ automatically navigating a site and examining output for
+ correctness.
+ This is the job of a web tester.
+ </p>
+ <p>
+ The web testing in SimpleTest is fairly primitive, as there is
+ no JavaScript.
+ Most other browser operations are simulated.
+ </p>
+ <p>
+ To give an idea here is a trivial example where a home
+ page is fetched, from which we navigate to an "about"
+ page and then test some client determined content.
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+<strong>require_once('simpletest/web_tester.php');</strong>
+
+class TestOfAbout extends <strong>WebTestCase</strong> {
+ function testOurAboutPageGivesFreeReignToOurEgo() {
+ <strong>$this-&gt;get('http://test-server/index.php');
+ $this-&gt;click('About');
+ $this-&gt;assertTitle('About why we are so great');
+ $this-&gt;assertText('We are really great');</strong>
+ }
+}
+?&gt;
+</pre>
+ With this code as an acceptance test, you can ensure that
+ the content always meets the specifications of both the
+ developers, and the other project stakeholders.
+ </p>
+ <p>
+ You can navigate forms too...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('simpletest/web_tester.php');
+
+class TestOfRankings extends WebTestCase {
+ function testWeAreTopOfGoogle() {
+ $this-&gt;get('http://google.com/');
+ $this-&gt;setField('q', 'simpletest');
+ $this-&gt;click("I'm Feeling Lucky");
+ $this-&gt;assertTitle('SimpleTest - Unit Testing for PHP');
+ }
+}
+?&gt;
+</pre>
+ ...although this could violate Google's(tm) terms and conditions.
+ </p>
+ <p>
+ For more information about web testing, see the
+ <a href="browser_documentation.html">scriptable
+ browser documentation</a> and the
+ <a href="web_tester_documentation.html">WebTestCase</a>.
+ </p>
+ <p>
+ <a href="http://sourceforge.net/projects/simpletest/"><img src="http://sourceforge.net/sflogo.php?group_id=76550&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo"></a>
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ <a href="https://sourceforge.net/project/showfiles.php?group_id=76550&amp;release_id=153280">Download PHP Simple Test</a>
+ from <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
+ gives full detail on the classes and assertions available.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<span class="chosen">SimpleTest</span>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/mock_objects_documentation.html b/vendors/simpletest/docs/en/mock_objects_documentation.html
new file mode 100644
index 000000000..c3d002277
--- /dev/null
+++ b/vendors/simpletest/docs/en/mock_objects_documentation.html
@@ -0,0 +1,757 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>SimpleTest for PHP mock objects documentation</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <span class="chosen">Mock objects</span>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Mock objects documentation</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#what">What are mock objects?</a>
+ </li>
+<li>
+ <a href="#creation">Creating mock objects</a>.
+ </li>
+<li>
+ <a href="#stub">Mocks as actors</a> or stubs.
+ </li>
+<li>
+ <a href="#expectations">Mocks as critics</a> with expectations.
+ </li>
+<li>
+ <a href="#approaches">Other approaches</a> including mock libraries.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="what"><h2>What are mock objects?</h2></a></p>
+ <p>
+ Mock objects have two roles during a test case: actor and critic.
+ </p>
+ <p>
+ The actor behaviour is to simulate objects that are difficult to
+ set up or time consuming to set up for a test.
+ The classic example is a database connection.
+ Setting up a test database at the start of each test would slow
+ testing to a crawl and would require the installation of the
+ database engine and test data on the test machine.
+ If we can simulate the connection and return data of our
+ choosing we not only win on the pragmatics of testing, but can
+ also feed our code spurious data to see how it responds.
+ We can simulate databases being down or other extremes
+ without having to create a broken database for real.
+ In other words, we get greater control of the test environment.
+ </p>
+ <p>
+ If mock objects only behaved as actors they would simply be
+ known as server stubs.
+ This was originally a pattern named by Robert Binder (Testing
+ object-oriented systems: models, patterns, and tools,
+ Addison-Wesley) in 1999.
+ </p>
+ <p>
+ A server stub is a simulation of an object or component.
+ It should exactly replace a component in a system for test
+ or prototyping purposes, but remain lightweight.
+ This allows tests to run more quickly, or if the simulated
+ class has not been written, to run at all.
+ </p>
+ <p>
+ However, the mock objects not only play a part (by supplying chosen
+ return values on demand) they are also sensitive to the
+ messages sent to them (via expectations).
+ By setting expected parameters for a method call they act
+ as a guard that the calls upon them are made correctly.
+ If expectations are not met they save us the effort of
+ writing a failed test assertion by performing that duty on our
+ behalf.
+ </p>
+ <p>
+ In the case of an imaginary database connection they can
+ test that the query, say SQL, was correctly formed by
+ the object that is using the connection.
+ Set them up with fairly tight expectations and you will
+ hardly need manual assertions at all.
+ </p>
+
+ <p><a class="target" name="creation"><h2>Creating mock objects</h2></a></p>
+ <p>
+ In the same way that we create server stubs, all we need is an
+ existing class, say a database connection that looks like this...
+<pre>
+<strong>class DatabaseConnection {
+ function DatabaseConnection() {
+ }
+
+ function query() {
+ }
+
+ function selectQuery() {
+ }
+}</strong>
+</pre>
+ The class does not need to have been implemented yet.
+ To create a mock version of the class we need to include the
+ mock object library and run the generator...
+<pre>
+<strong>require_once('simpletest/unit_tester.php');
+require_once('simpletest/mock_objects.php');
+require_once('database_connection.php');
+
+Mock::generate('DatabaseConnection');</strong>
+</pre>
+ This generates a clone class called
+ <span class="new_code">MockDatabaseConnection</span>.
+ We can now create instances of the new class within
+ our test case...
+<pre>
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/mock_objects.php');
+require_once('database_connection.php');
+
+Mock::generate('DatabaseConnection');
+<strong>
+class MyTestCase extends UnitTestCase {
+
+ function testSomething() {
+ $connection = &amp;new MockDatabaseConnection();
+ }
+}</strong>
+</pre>
+ Unlike the generated stubs the mock constructor needs a reference
+ to the test case so that it can dispatch passes and failures while
+ checking its expectations.
+ This means that mock objects can only be used within test cases.
+ Despite this their extra power means that stubs are hardly ever used
+ if mocks are available.
+ </p>
+ <p>
+ <a class="target" name="stub"><h2>Mocks as actors</h2></a>
+ </p>
+ <p>
+ The mock version of a class has all the methods of the original,
+ so that operations like
+ <span class="new_code">$connection-&gt;query()</span> are still
+ legal.
+ The return value will be <span class="new_code">null</span>,
+ but we can change that with...
+<pre>
+<strong>$connection-&gt;setReturnValue('query', 37)</strong>
+</pre>
+ Now every time we call
+ <span class="new_code">$connection-&gt;query()</span> we get
+ the result of 37.
+ We can set the return value to anything, say a hash of
+ imaginary database results or a list of persistent objects.
+ Parameters are irrelevant here, we always get the same
+ values back each time once they have been set up this way.
+ That may not sound like a convincing replica of a
+ database connection, but for the half a dozen lines of
+ a test method it is usually all you need.
+ </p>
+ <p>
+ We can also add extra methods to the mock when generating it
+ and choose our own class name...
+<pre>
+<strong>Mock::generate('DatabaseConnection', 'MyMockDatabaseConnection', array('setOptions'));</strong>
+</pre>
+ Here the mock will behave as if the <span class="new_code">setOptions()</span>
+ existed in the original class.
+ This is handy if a class has used the PHP <span class="new_code">overload()</span>
+ mechanism to add dynamic methods.
+ You can create a special mock to simulate this situation.
+ </p>
+ <p>
+ Things aren't always that simple though.
+ One common problem is iterators, where constantly returning
+ the same value could cause an endless loop in the object
+ being tested.
+ For these we need to set up sequences of values.
+ Let's say we have a simple iterator that looks like this...
+<pre>
+class Iterator {
+ function Iterator() {
+ }
+
+ function next() {
+ }
+}
+</pre>
+ This is about the simplest iterator you could have.
+ Assuming that this iterator only returns text until it
+ reaches the end, when it returns false, we can simulate it
+ with...
+<pre>
+Mock::generate('Iterator');
+
+class IteratorTest extends UnitTestCase() {
+
+ function testASequence() {<strong>
+ $iterator = &amp;new MockIterator();
+ $iterator-&gt;setReturnValue('next', false);
+ $iterator-&gt;setReturnValueAt(0, 'next', 'First string');
+ $iterator-&gt;setReturnValueAt(1, 'next', 'Second string');</strong>
+ ...
+ }
+}
+</pre>
+ When <span class="new_code">next()</span> is called on the
+ mock iterator it will first return "First string",
+ on the second call "Second string" will be returned
+ and on any other call <span class="new_code">false</span> will
+ be returned.
+ The sequenced return values take precedence over the constant
+ return value.
+ The constant one is a kind of default if you like.
+ </p>
+ <p>
+ Another tricky situation is an overloaded
+ <span class="new_code">get()</span> operation.
+ An example of this is an information holder with name/value pairs.
+ Say we have a configuration class like...
+<pre>
+class Configuration {
+ function Configuration() {
+ }
+
+ function getValue($key) {
+ }
+}
+</pre>
+ This is a classic situation for using mock objects as
+ actual configuration will vary from machine to machine,
+ hardly helping the reliability of our tests if we use it
+ directly.
+ The problem though is that all the data comes through the
+ <span class="new_code">getValue()</span> method and yet
+ we want different results for different keys.
+ Luckily the mocks have a filter system...
+<pre>
+<strong>$config = &amp;new MockConfiguration();
+$config-&gt;setReturnValue('getValue', 'primary', array('db_host'));
+$config-&gt;setReturnValue('getValue', 'admin', array('db_user'));
+$config-&gt;setReturnValue('getValue', 'secret', array('db_password'));</strong>
+</pre>
+ The extra parameter is a list of arguments to attempt
+ to match.
+ In this case we are trying to match only one argument which
+ is the look up key.
+ Now when the mock object has the
+ <span class="new_code">getValue()</span> method invoked
+ like this...
+<pre>
+$config-&gt;getValue('db_user')
+</pre>
+ ...it will return "admin".
+ It finds this by attempting to match the calling arguments
+ to its list of returns one after another until
+ a complete match is found.
+ </p>
+ <p>
+ You can set a default argument argument like so...
+<pre><strong>
+$config-&gt;setReturnValue('getValue', false, array('*'));</strong>
+</pre>
+ This is not the same as setting the return value without
+ any argument requirements like this...
+<pre><strong>
+$config-&gt;setReturnValue('getValue', false);</strong>
+</pre>
+ In the first case it will accept any single argument,
+ but exactly one is required.
+ In the second case any number of arguments will do and
+ it acts as a catchall after all other matches.
+ Note that if we add further single parameter options after
+ the wildcard in the first case, they will be ignored as the wildcard
+ will match first.
+ With complex parameter lists the ordering could be important
+ or else desired matches could be masked by earlier wildcard
+ ones.
+ Declare the most specific matches first if you are not sure.
+ </p>
+ <p>
+ There are times when you want a specific object to be
+ dished out by the mock rather than a copy.
+ The PHP4 copy semantics force us to use a different method
+ for this.
+ You might be simulating a container for example...
+<pre>
+class Thing {
+}
+
+class Vector {
+ function Vector() {
+ }
+
+ function get($index) {
+ }
+}
+</pre>
+ In this case you can set a reference into the mock's
+ return list...
+<pre>
+$thing = &amp;new Thing();<strong>
+$vector = &amp;new MockVector();
+$vector-&gt;setReturnReference('get', $thing, array(12));</strong>
+</pre>
+ With this arrangement you know that every time
+ <span class="new_code">$vector-&gt;get(12)</span> is
+ called it will return the same
+ <span class="new_code">$thing</span> each time.
+ This is compatible with PHP5 as well.
+ </p>
+ <p>
+ These three factors, timing, parameters and whether to copy,
+ can be combined orthogonally.
+ For example...
+<pre>
+$complex = &amp;new MockComplexThing();
+$stuff = &amp;new Stuff();<strong>
+$complex-&gt;setReturnReferenceAt(3, 'get', $stuff, array('*', 1));</strong>
+</pre>
+ This will return the <span class="new_code">$stuff</span> only on the third
+ call and only if two parameters were set the second of
+ which must be the integer 1.
+ That should cover most simple prototyping situations.
+ </p>
+ <p>
+ A final tricky case is one object creating another, known
+ as a factory pattern.
+ Suppose that on a successful query to our imaginary
+ database, a result set is returned as an iterator with
+ each call to <span class="new_code">next()</span> giving
+ one row until false.
+ This sounds like a simulation nightmare, but in fact it can all
+ be mocked using the mechanics above.
+ </p>
+ <p>
+ Here's how...
+<pre>
+Mock::generate('DatabaseConnection');
+Mock::generate('ResultIterator');
+
+class DatabaseTest extends UnitTestCase {
+
+ function testUserFinder() {<strong>
+ $result = &amp;new MockResultIterator();
+ $result-&gt;setReturnValue('next', false);
+ $result-&gt;setReturnValueAt(0, 'next', array(1, 'tom'));
+ $result-&gt;setReturnValueAt(1, 'next', array(3, 'dick'));
+ $result-&gt;setReturnValueAt(2, 'next', array(6, 'harry'));
+
+ $connection = &amp;new MockDatabaseConnection();
+ $connection-&gt;setReturnValue('query', false);
+ $connection-&gt;setReturnReference(
+ 'query',
+ $result,
+ array('select id, name from users'));</strong>
+
+ $finder = &amp;new UserFinder($connection);
+ $this-&gt;assertIdentical(
+ $finder-&gt;findNames(),
+ array('tom', 'dick', 'harry'));
+ }
+}
+</pre>
+ Now only if our
+ <span class="new_code">$connection</span> is called with the correct
+ <span class="new_code">query()</span> will the
+ <span class="new_code">$result</span> be returned that is
+ itself exhausted after the third call to <span class="new_code">next()</span>.
+ This should be enough
+ information for our <span class="new_code">UserFinder</span> class,
+ the class actually
+ being tested here, to come up with goods.
+ A very precise test and not a real database in sight.
+ </p>
+
+ <p><a class="target" name="expectations"><h2>Mocks as critics</h2></a></p>
+ <p>
+ Although the server stubs approach insulates your tests from
+ real world disruption, it is only half the benefit.
+ You can have the class under test receiving the required
+ messages, but is your new class sending correct ones?
+ Testing this can get messy without a mock objects library.
+ </p>
+ <p>
+ By way of example, suppose we have a
+ <span class="new_code">SessionPool</span> class that we
+ want to add logging to.
+ Rather than grow the original class into something more
+ complicated, we want to add this behaviour with a decorator (GOF).
+ The <span class="new_code">SessionPool</span> code currently looks
+ like this...
+<pre>
+<strong>class SessionPool {
+ function SessionPool() {
+ ...
+ }
+
+ function &amp;findSession($cookie) {
+ ...
+ }
+ ...
+}
+
+class Session {
+ ...
+}</strong>
+</pre>
+ While our logging code looks like this...
+<pre>
+<strong>
+class Log {
+ function Log() {
+ ...
+ }
+
+ function message() {
+ ...
+ }
+}
+
+class LoggingSessionPool {
+ function LoggingSessionPool(&amp;$session_pool, &amp;$log) {
+ ...
+ }
+
+ function &amp;findSession($cookie) {
+ ...
+ }
+ ...
+}</strong>
+</pre>
+ Out of all of this, the only class we want to test here
+ is the <span class="new_code">LoggingSessionPool</span>.
+ In particular we would like to check that the
+ <span class="new_code">findSession()</span> method is
+ called with the correct session ID in the cookie and that
+ it sent the message "Starting session $cookie"
+ to the logger.
+ </p>
+ <p>
+ Despite the fact that we are testing only a few lines of
+ production code, here is what we would have to do in a
+ conventional test case:
+ <ol>
+ <li>Create a log object.</li>
+ <li>Set a directory to place the log file.</li>
+ <li>Set the directory permissions so we can write the log.</li>
+ <li>Create a <span class="new_code">SessionPool</span> object.</li>
+ <li>Hand start a session, which probably does lot's of things.</li>
+ <li>Invoke <span class="new_code">findSession()</span>.</li>
+ <li>Read the new Session ID (hope there is an accessor!).</li>
+ <li>Raise a test assertion to confirm that the ID matches the cookie.</li>
+ <li>Read the last line of the log file.</li>
+ <li>Pattern match out the extra logging timestamps, etc.</li>
+ <li>Assert that the session message is contained in the text.</li>
+ </ol>
+ It is hardly surprising that developers hate writing tests
+ when they are this much drudgery.
+ To make things worse, every time the logging format changes or
+ the method of creating new sessions changes, we have to rewrite
+ parts of this test even though this test does not officially
+ test those parts of the system.
+ We are creating headaches for the writers of these other classes.
+ </p>
+ <p>
+ Instead, here is the complete test method using mock object magic...
+<pre>
+Mock::generate('Session');
+Mock::generate('SessionPool');
+Mock::generate('Log');
+
+class LoggingSessionPoolTest extends UnitTestCase {
+ ...
+ function testFindSessionLogging() {<strong>
+ $session = &amp;new MockSession();
+ $pool = &amp;new MockSessionPool();
+ $pool-&gt;setReturnReference('findSession', $session);
+ $pool-&gt;expectOnce('findSession', array('abc'));
+
+ $log = &amp;new MockLog();
+ $log-&gt;expectOnce('message', array('Starting session abc'));
+
+ $logging_pool = &amp;new LoggingSessionPool($pool, $log);
+ $this-&gt;assertReference($logging_pool-&gt;findSession('abc'), $session);</strong>
+ }
+}
+</pre>
+ We start by creating a dummy session.
+ We don't have to be too fussy about this as the check
+ for which session we want is done elsewhere.
+ We only need to check that it was the same one that came
+ from the session pool.
+ </p>
+ <p>
+ <span class="new_code">findSession()</span> is a factory
+ method the simulation of which is described <a href="#stub">above</a>.
+ The point of departure comes with the first
+ <span class="new_code">expectOnce()</span> call.
+ This line states that whenever
+ <span class="new_code">findSession()</span> is invoked on the
+ mock, it will test the incoming arguments.
+ If it receives the single argument of a string "abc"
+ then a test pass is sent to the unit tester, otherwise a fail is
+ generated.
+ This was the part where we checked that the right session was asked for.
+ The argument list follows the same format as the one for setting
+ return values.
+ You can have wildcards and sequences and the order of
+ evaluation is the same.
+ </p>
+ <p>
+ We use the same pattern to set up the mock logger.
+ We tell it that it should have
+ <span class="new_code">message()</span> invoked
+ once only with the argument "Starting session abc".
+ By testing the calling arguments, rather than the logger output,
+ we insulate the test from any display changes in the logger.
+ </p>
+ <p>
+ We start to run our tests when we create the new
+ <span class="new_code">LoggingSessionPool</span> and feed
+ it our preset mock objects.
+ Everything is now under our control.
+ </p>
+ <p>
+ This is still quite a bit of test code, but the code is very
+ strict.
+ If it still seems rather daunting there is a lot less of it
+ than if we tried this without mocks and this particular test,
+ interactions rather than output, is always more work to set
+ up.
+ More often you will be testing more complex situations without
+ needing this level or precision.
+ Also some of this can be refactored into a test case
+ <span class="new_code">setUp()</span> method.
+ </p>
+ <p>
+ Here is the full list of expectations you can set on a mock object
+ in <a href="http://www.lastcraft.com/simple_test.php">SimpleTest</a>...
+ <table>
+<thead>
+ <tr>
+<th>Expectation</th>
+<th>Needs <span class="new_code">tally()</span>
+</th>
+</tr>
+ </thead>
+<tbody>
+<tr>
+ <td><span class="new_code">expect($method, $args)</span></td>
+ <td style="text-align: center">No</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectAt($timing, $method, $args)</span></td>
+ <td style="text-align: center">No</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectCallCount($method, $count)</span></td>
+ <td style="text-align: center">Yes</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectMaximumCallCount($method, $count)</span></td>
+ <td style="text-align: center">No</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectMinimumCallCount($method, $count)</span></td>
+ <td style="text-align: center">Yes</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectNever($method)</span></td>
+ <td style="text-align: center">No</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectOnce($method, $args)</span></td>
+ <td style="text-align: center">Yes</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectAtLeastOnce($method, $args)</span></td>
+ <td style="text-align: center">Yes</td>
+ </tr>
+ </tbody>
+</table>
+ Where the parameters are...
+ <dl>
+ <dt class="new_code">$method</dt>
+ <dd>The method name, as a string, to apply the condition to.</dd>
+ <dt class="new_code">$args</dt>
+ <dd>
+ The arguments as a list. Wildcards can be included in the same
+ manner as for <span class="new_code">setReturn()</span>.
+ This argument is optional for <span class="new_code">expectOnce()</span>
+ and <span class="new_code">expectAtLeastOnce()</span>.
+ </dd>
+ <dt class="new_code">$timing</dt>
+ <dd>
+ The only point in time to test the condition.
+ The first call starts at zero.
+ </dd>
+ <dt class="new_code">$count</dt>
+ <dd>The number of calls expected.</dd>
+ </dl>
+ The method <span class="new_code">expectMaximumCallCount()</span>
+ is slightly different in that it will only ever generate a failure.
+ It is silent if the limit is never reached.
+ </p>
+ <p>
+ Also if you have juste one call in your test, make sure you're using
+ <span class="new_code">expectOnce</span>.<br>
+ Using <span class="new_code">$mocked-&gt;expectAt(0, 'method', 'args);</span>
+ on its own will not be catched :
+ checking the arguments and the overall call count
+ are currently independant.
+ </p>
+ <p>
+ Like the assertions within test cases, all of the expectations
+ can take a message override as an extra parameter.
+ Also the original failure message can be embedded in the output
+ as "%s".
+ </p>
+
+ <p><a class="target" name="approaches"><h2>Other approaches</h2></a></p>
+ <p>
+ There are three approaches to creating mocks including the one
+ that SimpleTest employs.
+ Coding them by hand using a base class, generating them to
+ a file and dynamically generating them on the fly.
+ </p>
+ <p>
+ Mock objects generated with <a href="simple_test.html">SimpleTest</a>
+ are dynamic.
+ They are created at run time in memory, using
+ <span class="new_code">eval()</span>, rather than written
+ out to a file.
+ This makes the mocks easy to create, a one liner,
+ especially compared with hand
+ crafting them in a parallel class hierarchy.
+ The problem is that the behaviour is usually set up in the tests
+ themselves.
+ If the original objects change the mock versions
+ that the tests rely on can get out of sync.
+ This can happen with the parallel hierarchy approach as well,
+ but is far more quickly detected.
+ </p>
+ <p>
+ The solution, of course, is to add some real integration
+ tests.
+ You don't need very many and the convenience gained
+ from the mocks more than outweighs the small amount of
+ extra testing.
+ You cannot trust code that was only tested with mocks.
+ </p>
+ <p>
+ If you are still determined to build static libraries of mocks
+ because you want to simulate very specific behaviour, you can
+ achieve the same effect using the SimpleTest class generator.
+ In your library file, say <em>mocks/connection.php</em> for a
+ database connection, create a mock and inherit to override
+ special methods or add presets...
+<pre>
+&lt;?php
+ require_once('simpletest/mock_objects.php');
+ require_once('../classes/connection.php');
+<strong>
+ Mock::generate('Connection', 'BasicMockConnection');
+ class MockConnection extends BasicMockConnection {
+ function MockConnection() {
+ $this-&gt;BasicMockConnection();
+ $this-&gt;setReturn('query', false);
+ }
+ }</strong>
+?&gt;
+</pre>
+ The generate call tells the class generator to create
+ a class called <span class="new_code">BasicMockConnection</span>
+ rather than the usual <span class="new_code">MockConnection</span>.
+ We then inherit from this to get our version of
+ <span class="new_code">MockConnection</span>.
+ By intercepting in this way we can add behaviour, here setting
+ the default value of <span class="new_code">query()</span> to be false.
+ By using the default name we make sure that the mock class
+ generator will not recreate a different one when invoked elsewhere in the
+ tests.
+ It never creates a class if it already exists.
+ As long as the above file is included first then all tests
+ that generated <span class="new_code">MockConnection</span> should
+ now be using our one instead.
+ If we don't get the order right and the mock library
+ creates one first then the class creation will simply fail.
+ </p>
+ <p>
+ Use this trick if you find you have a lot of common mock behaviour
+ or you are getting frequent integration problems at later
+ stages of testing.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ The original
+ <a href="http://www.mockobjects.com/">Mock objects</a> paper.
+ </li>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest home page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <span class="chosen">Mock objects</span>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/overview.html b/vendors/simpletest/docs/en/overview.html
new file mode 100644
index 000000000..5bed89e51
--- /dev/null
+++ b/vendors/simpletest/docs/en/overview.html
@@ -0,0 +1,486 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>
+ Overview and feature list for the SimpleTest PHP unit tester and web tester
+ </title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <span class="chosen">Overview</span>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Overview of SimpleTest</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#summary">Quick summary</a>
+ of the SimpleTest tool for PHP.
+ </li>
+<li>
+ <a href="#features">List of features</a>,
+ both current ones and those planned.
+ </li>
+<li>
+ There are plenty of <a href="#resources">unit testing resources</a>
+ on the web.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="summary"><h2>What is SimpleTest?</h2></a></p>
+ <p>
+ The heart of SimpleTest is a testing framework built around
+ test case classes.
+ These are written as extensions of base test case classes,
+ each extended with methods that actually contain test code.
+ Top level test scripts then invoke the <span class="new_code">run()</span>
+ methods on every one of these test cases in order.
+ Each test method is written to invoke various assertions that
+ the developer expects to be true such as
+ <span class="new_code">assertEqual()</span>.
+ If the expectation is correct, then a successful result is dispatched to the
+ observing test reporter, but any failure triggers an alert
+ and a description of the mismatch.
+ </p>
+ <p>
+ A <a href="unit_test_documentation.html">test case</a> looks like this...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+
+class <strong>MyTestCase</strong> extends UnitTestCase {
+ <strong>
+ function testCreatedLogFile() {
+ $log = &amp;new Log('my.log');
+ $log-&gt;message('Hello');
+ $this-&gt;assertTrue(file_exists('my.log'));
+ }</strong>
+}
+?&gt;
+</pre>
+ </p>
+ <p>
+ These tools are designed for the developer.
+ Tests are written in the PHP language itself more or less
+ as the application itself is built.
+ The advantage of using PHP itself as the testing language is that
+ there are no new languages to learn, testing can start straight away,
+ and the developer can test any part of the code.
+ Basically, all parts that can be accessed by the application code can also be
+ accessed by the test code, if they are in the same programming language.
+ </p>
+ <p>
+ The simplest type of test case is the
+ <a href="unit_tester_documentation.html">UnitTestCase</a>.
+ This class of test case includes standard tests for equality,
+ references and pattern matching.
+ All these test the typical expectations of what you would
+ expect the result of a function or method to be.
+ This is by far the most common type of test in the daily
+ routine of development, making up about 95% of test cases.
+ </p>
+ <p>
+ The top level task of a web application though is not to
+ produce correct output from its methods and objects, but
+ to generate web pages.
+ The <a href="web_tester_documentation.html">WebTestCase</a> class tests web
+ pages.
+ It simulates a web browser requesting a page, complete with
+ cookies, proxies, secure connections, authentication, forms, frames and most
+ navigation elements.
+ With this type of test case, the developer can assert that
+ information is present in the page and that forms and
+ sessions are handled correctly.
+ </p>
+ <p>
+ A <a href="web_tester_documentation.html">WebTestCase</a> looks like this...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('simpletest/web_tester.php');
+
+class <strong>MySiteTest</strong> extends WebTestCase {
+ <strong>
+ function testHomePage() {
+ $this-&gt;get('http://www.my-site.com/index.php');
+ $this-&gt;assertTitle('My Home Page');
+ $this-&gt;clickLink('Contact');
+ $this-&gt;assertTitle('Contact me');
+ $this-&gt;assertPattern('/Email me at/');
+ }</strong>
+}
+?&gt;
+</pre>
+ </p>
+
+ <p><a class="target" name="features"><h2>Feature list</h2></a></p>
+ <p>
+ The following is a very rough outline of past and future features
+ and their expected point of release.
+ I am afraid it is liable to change without warning, as meeting the
+ milestones rather depends on time available.
+ Green stuff has been coded, but not necessarily released yet.
+ If you have a pressing need for a green but unreleased feature
+ then you should check-out the code from Sourceforge SVN directly.
+ <table>
+<thead>
+ <tr>
+<th>Feature</th>
+<th>Description</th>
+<th>Release</th>
+</tr>
+ </thead>
+<tbody>
+<tr>
+ <td>Unit test case</td>
+ <td>Core test case class and assertions</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Html display</td>
+ <td>Simplest possible display</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Autoloading of test cases</td>
+ <td>
+ Reading a file with test cases and loading them into a
+ group test automatically
+ </td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Mock objects</td>
+ <td>
+ Objects capable of simulating other objects removing
+ test dependencies
+ </td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Web test case</td>
+ <td>Allows link following and title tag matching</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Partial mocks</td>
+ <td>
+ Mocking parts of a class for testing less than a class
+ or for complex simulations
+ </td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Web cookie handling</td>
+ <td>Correct handling of cookies when fetching pages</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Following redirects</td>
+ <td>Page fetching automatically follows 300 redirects</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Form parsing</td>
+ <td>Ability to submit simple forms and read default form values</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Command line interface</td>
+ <td>Test display without the need of a web browser</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Exposure of expectation classes</td>
+ <td>Can create precise tests with mocks as well as test cases</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>XML output and parsing</td>
+ <td>
+ Allows multi host testing and the integration of acceptance
+ testing extensions
+ </td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Browser component</td>
+ <td>
+ Exposure of lower level web browser interface for more
+ detailed test cases
+ </td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>HTTP authentication</td>
+ <td>
+ Fetching protected web pages with basic authentication
+ only
+ </td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>SSL support</td>
+ <td>Can connect to https: pages</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Proxy support</td>
+ <td>Can connect via. common proxies</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>Frames support</td>
+ <td>Handling of frames in web test cases</td>
+ <td style="color: green;">1.0</td>
+ </tr>
+ <tr>
+ <td>File upload testing</td>
+ <td>Can simulate the input type file tag</td>
+ <td style="color: green;">1.0.1</td>
+ </tr>
+ <tr>
+ <td>Mocking interfaces</td>
+ <td>
+ Can generate mock objects to interfaces as well as classes
+ and class interfaces are carried for type hints
+ </td>
+ <td style="color: green;">1.0.1</td>
+ </tr>
+ <tr>
+ <td>Testing exceptions</td>
+ <td>Similar to testing PHP errors</td>
+ <td style="color: green;">1.0.1</td>
+ </tr>
+ <tr>
+ <td>HTML label support</td>
+ <td>Can access all controls using the visual label</td>
+ <td style="color: green;">1.0.1</td>
+ </tr>
+ <tr>
+ <td>Base tag support</td>
+ <td>Respects page base tag when clicking</td>
+ <td style="color: green;">1.0.1</td>
+ </tr>
+ <tr>
+ <td>PHP 5 E_STRICT compliant</td>
+ <td>PHP 5 only version that works with the E_STRICT error level</td>
+ <td style="color: red;">1.1</td>
+ </tr>
+ <tr>
+ <td>BDD style fixtures</td>
+ <td>Can import fixtures using a mixin like given() method</td>
+ <td style="color: red;">1.5</td>
+ </tr>
+ <tr>
+ <td>Reporting machinery enhancements</td>
+ <td>Improved message passing for better cooperation with IDEs</td>
+ <td style="color: red;">1.5</td>
+ </tr>
+ <tr>
+ <td>Fluent mock interface</td>
+ <td>More flexible and concise mock objects</td>
+ <td style="color: red;">1.6</td>
+ </tr>
+ <tr>
+ <td>Localisation</td>
+ <td>Messages abstracted and code generated</td>
+ <td style="color: red;">1.6</td>
+ </tr>
+ <tr>
+ <td>CSS selectors</td>
+ <td>HTML content can be examined using CSS selectors</td>
+ <td style="color: red;">1.7</td>
+ </tr>
+ <tr>
+ <td>HTML table assertions</td>
+ <td>Can match HTML or table elements to expectations</td>
+ <td style="color: red;">1.7</td>
+ </tr>
+ <tr>
+ <td>Unified acceptance testing model</td>
+ <td>Content searchable through selectors combined with expectations</td>
+ <td style="color: red;">1.7</td>
+ </tr>
+ <tr>
+ <td>DatabaseTestCase</td>
+ <td>SQL selectors and DB drivers</td>
+ <td style="color: red;">1.7</td>
+ </tr>
+ <tr>
+ <td>IFrame support</td>
+ <td>Reads IFrame content that can be refreshed</td>
+ <td style="color: red;">1.8</td>
+ </tr>
+ <tr>
+ <td>Alternate HTML parsers</td>
+ <td>Can detect compiled parsers for performance improvements</td>
+ <td style="color: red;">1.8</td>
+ </tr>
+ <tr>
+ <td>Integrated Selenium support</td>
+ <td>Easy to use built in Selenium driver and tutorial</td>
+ <td style="color: red;">1.9</td>
+ </tr>
+ <tr>
+ <td>Code coverage</td>
+ <td>Reports using the bundled tool when using XDebug</td>
+ <td style="color: red;">1.9</td>
+ </tr>
+ <tr>
+ <td>Deprecation of old methods</td>
+ <td>Simpler interface for SimpleTest2</td>
+ <td style="color: red;">2.0</td>
+ </tr>
+ <tr>
+ <td>Javascript suport</td>
+ <td>Use of PECL module to add Javascript to the native browser</td>
+ <td style="color: red;">3.0</td>
+ </tr>
+ </tbody>
+</table>
+ PHP5 migraton will start straight after the version 1.0.1 series,
+ whereupon only PHP 5.1+ will be supported.
+ SimpleTest is currently compatible with PHP 5, but will not
+ make use of all of the new features until version 1.1.
+ </p>
+
+ <p><a class="target" name="resources"><h2>Web resources for testing</h2></a></p>
+ <p>
+ Process is at least as important as tools.
+ The type of process that makes the heaviest use of a developer's
+ testing tool is of course
+ <a href="http://www.extremeprogramming.org/">Extreme Programming</a>.
+ This is one of the
+ <a href="http://www.agilealliance.com/articles/index">Agile Methodologies</a>
+ which combine various practices to "flatten the cost curve" of software development.
+ More extreme still is <a href="http://www.testdriven.com/modules/news/">Test Driven Development</a>,
+ where you very strictly adhere to the rule of no coding until you have a test.
+ If you're more of a planner, or believe that experience trumps evolution,
+ you may prefer the
+ <a href="http://www.therationaledge.com/content/dec_01/f_spiritOfTheRUP_pk.html">RUP</a> approach.
+ I haven't tried it, but even I can see that you will need test tools (see figure 9).
+ </p>
+ <p>
+ Most unit testers clone <a href="http://www.junit.org/">JUnit</a> to some degree,
+ as far as the interface at least. There is a wealth of information on the
+ JUnit site including the
+ <a href="http://junit.sourceforge.net/doc/faq/faq.htm">FAQ</a>
+ which contains plenty of general advice on testing.
+ Once you get bitten by the bug you will certainly appreciate the phrase
+ <a href="http://junit.sourceforge.net/doc/testinfected/testing.htm">test infected</a>
+ coined by Eric Gamma.
+ If you are still reviewing which unit tester to use you can find pretty complete
+ lists from
+ <a href="http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks">Wikipedia</a>,
+ <a href="http://www.testingfaqs.org/t-unit.html">Software testing FAQ</a>,
+ and <a href="http://www.opensourcetesting.org/functional.php">Open source testing</a>.
+ </p>
+ <p>
+ There is still very little material on using mock objects, which is a shame
+ as unit testing without them is a lot more work.
+ The <a href="http://www.sidewize.com/company/mockobjects.pdf">original mock objects paper</a>
+ is very Java focused, but still worth a read.
+ The most authoritive sources are probably
+ <a href="http://mockobjects.com">the original mock objects site</a> and
+ <a href="http://jmock.org/">JMock</a>.
+ Java centric, but tucked away in PDFs they contain some deep knowledge on using mocks from the
+ extended experience of the concept inventors.
+ As a new technology there are plenty of discussions and debate on how to use mocks,
+ often on Wikis such as
+ <a href="http://xpdeveloper.com/cgi-bin/oldwiki.cgi?MockObjects">Extreme Tuesday</a>
+ or <a href="http://www.mockobjects.com/MocksObjectsPaper.html">www.mockobjects.com</a>
+ or <a href="http://c2.com/cgi/wiki?MockObject">the original C2 Wiki</a>.
+ Injecting mocks into a class is the main area of debate for which this
+ <a href="http://www-106.ibm.com/developerworks/java/library/j-mocktest.html">paper on IBM</a>
+ makes a good starting point.
+ </p>
+ <p>
+ There are plenty of web testing tools, but the scriptable ones
+ are mostly are written in Java and
+ tutorials and advice are rather thin on the ground.
+ The only hope is to look at the documentation for
+ <a href="http://httpunit.sourceforge.net/">HTTPUnit</a>,
+ <a href="http://htmlunit.sourceforge.net/">HTMLUnit</a>
+ or <a href="http://jwebunit.sourceforge.net/">JWebUnit</a> and hope for clues.
+ There are some XML driven test frameworks, but again most
+ require Java to run.
+ </p>
+ <p>
+ Most significant is a new generation of tools that run directly in the web browser
+ are now available.
+ These include
+ <a href="http://www.openqa.org/selenium/">Selenium</a> and
+ <a href="http://wtr.rubyforge.org/">Watir</a>.
+ They are non-trivial to set up and slow to run, but can essentially test anything.
+ As SimpleTest does not support JavaScript you would probably
+ have to look at these tools anyway if you have highly dynamic
+ pages.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ <a href="unit_test_documentation.html">Documentation for SimpleTest</a>.
+ </li>
+<li>
+ <a href="http://www.lastcraft.com/first_test_tutorial.php">How to write PHP test cases</a>
+ is a fairly advanced tutorial.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">SimpleTest API</a> from phpdoc.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <span class="chosen">Overview</span>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/partial_mocks_documentation.html b/vendors/simpletest/docs/en/partial_mocks_documentation.html
new file mode 100644
index 000000000..4cae18c9d
--- /dev/null
+++ b/vendors/simpletest/docs/en/partial_mocks_documentation.html
@@ -0,0 +1,445 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>SimpleTest for PHP partial mocks documentation</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <span class="chosen">Partial mocks</span>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Partial mock objects documentation</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#inject">The mock injection problem</a>.
+ </li>
+<li>
+ Moving creation to a <a href="#creation">protected factory</a> method.
+ </li>
+<li>
+ <a href="#partial">Partial mocks</a> generate subclasses.
+ </li>
+<li>
+ Partial mocks <a href="#less">test less than a class</a>.
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ A partial mock is simply a pattern to alleviate a specific problem
+ in testing with mock objects,
+ that of getting mock objects into tight corners.
+ It's quite a limited tool and possibly not even a good idea.
+ It is included with SimpleTest because I have found it useful
+ on more than one occasion and has saved a lot of work at that point.
+ </p>
+
+ <p><a class="target" name="inject"><h2>The mock injection problem</h2></a></p>
+ <p>
+ When one object uses another it is very simple to just pass a mock
+ version in already set up with its expectations.
+ Things are rather tricker if one object creates another and the
+ creator is the one you want to test.
+ This means that the created object should be mocked, but we can
+ hardly tell our class under test to create a mock instead.
+ The tested class doesn't even know it is running inside a test
+ after all.
+ </p>
+ <p>
+ For example, suppose we are building a telnet client and it
+ needs to create a network socket to pass its messages.
+ The connection method might look something like...
+<pre>
+<strong>&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...
+ function &amp;connect($ip, $port, $username, $password) {
+ $socket = &amp;new Socket($ip, $port);
+ $socket-&gt;read( ... );
+ ...
+ }
+}
+?&gt;</strong>
+</pre>
+ We would really like to have a mock object version of the socket
+ here, what can we do?
+ </p>
+ <p>
+ The first solution is to pass the socket in as a parameter,
+ forcing the creation up a level.
+ Having the client handle this is actually a very good approach
+ if you can manage it and should lead to factoring the creation from
+ the doing.
+ In fact, this is one way in which testing with mock objects actually
+ forces you to code more tightly focused solutions.
+ They improve your programming.
+ </p>
+ <p>
+ Here this would be...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...
+ <strong>function &amp;connect(&amp;$socket, $username, $password) {
+ $socket-&gt;read( ... );
+ ...
+ }</strong>
+}
+?&gt;
+</pre>
+ This means that the test code is typical for a test involving
+ mock objects.
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new Telnet();
+ $telnet-&gt;connect($socket, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ It is pretty obvious though that one level is all you can go.
+ You would hardly want your top level application creating
+ every low level file, socket and database connection ever
+ needed.
+ It wouldn't know the constructor parameters anyway.
+ </p>
+ <p>
+ The next simplest compromise is to have the created object passed
+ in as an optional parameter...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...<strong>
+ function &amp;connect($ip, $port, $username, $password, $socket = false) {
+ if (!$socket) {
+ $socket = &amp;new Socket($ip, $port);
+ }
+ $socket-&gt;read( ... );</strong>
+ ...
+ return $socket;
+ }
+}
+?&gt;
+</pre>
+ For a quick solution this is usually good enough.
+ The test now looks almost the same as if the parameter
+ was formally passed...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new Telnet();
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret', &amp;$socket);
+ ...</strong>
+ }
+}
+</pre>
+ The problem with this approach is its untidiness.
+ There is test code in the main class and parameters passed
+ in the test case that are never used.
+ This is a quick and dirty approach, but nevertheless effective
+ in most situations.
+ </p>
+ <p>
+ The next method is to pass in a factory object to do the creation...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {<strong>
+ function Telnet(&amp;$network) {
+ $this-&gt;_network = &amp;$network;
+ }</strong>
+ ...
+ function &amp;connect($ip, $port, $username, $password) {<strong>
+ $socket = &amp;$this-&gt;_network-&gt;createSocket($ip, $port);
+ $socket-&gt;read( ... );</strong>
+ ...
+ return $socket;
+ }
+}
+?&gt;
+</pre>
+ This is probably the most highly factored answer as creation
+ is now moved into a small specialist class.
+ The networking factory can now be tested separately, but mocked
+ easily when we are testing the telnet class...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $network = &amp;new MockNetwork($this);
+ $network-&gt;setReturnReference('createSocket', $socket);
+ $telnet = &amp;new Telnet($network);
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ The downside is that we are adding a lot more classes to the
+ library.
+ Also we are passing a lot of factories around which will
+ make the code a little less intuitive.
+ The most flexible solution, but the most complex.
+ </p>
+ <p>
+ Is there a middle ground?
+ </p>
+
+ <p><a class="target" name="creation"><h2>Protected factory method</h2></a></p>
+ <p>
+ There is a way we can circumvent the problem without creating
+ any new application classes, but it involves creating a subclass
+ when we do the actual testing.
+ Firstly we move the socket creation into its own method...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...
+ function &amp;connect($ip, $port, $username, $password) {<strong>
+ $socket = &amp;$this-&gt;_createSocket($ip, $port);</strong>
+ $socket-&gt;read( ... );
+ ...
+ }<strong>
+
+ function &amp;_createSocket($ip, $port) {
+ return new Socket($ip, $port);
+ }</strong>
+}
+?&gt;
+</pre>
+ This is the only change we make to the application code.
+ </p>
+ <p>
+ For the test case we have to create a subclass so that
+ we can intercept the socket creation...
+<pre>
+<strong>class TelnetTestVersion extends Telnet {
+ var $_mock;
+
+ function TelnetTestVersion(&amp;$mock) {
+ $this-&gt;_mock = &amp;$mock;
+ $this-&gt;Telnet();
+ }
+
+ function &amp;_createSocket() {
+ return $this-&gt;_mock;
+ }
+}</strong>
+</pre>
+ Here I have passed the mock in the constructor, but a
+ setter would have done just as well.
+ Note that the mock was set into the object variable
+ before the constructor was chained.
+ This is necessary in case the constructor calls
+ <span class="new_code">connect()</span>.
+ Otherwise it could get a null value from
+ <span class="new_code">_createSocket()</span>.
+ </p>
+ <p>
+ After the completion of all of this extra work the
+ actual test case is fairly easy.
+ We just test our new class instead...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new TelnetTestVersion($socket);
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ The new class is very simple of course.
+ It just sets up a return value, rather like a mock.
+ It would be nice if it also checked the incoming parameters
+ as well.
+ Just like a mock.
+ It seems we are likely to do this often, can
+ we automate the subclass creation?
+ </p>
+
+ <p><a class="target" name="partial"><h2>A partial mock</h2></a></p>
+ <p>
+ Of course the answer is "yes" or I would have stopped writing
+ this by now!
+ The previous test case was a lot of work, but we can
+ generate the subclass using a similar approach to the mock objects.
+ </p>
+ <p>
+ Here is the partial mock version of the test...
+<pre>
+<strong>Mock::generatePartial(
+ 'Telnet',
+ 'TelnetTestVersion',
+ array('_createSocket'));</strong>
+
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new TelnetTestVersion($this);
+ $telnet-&gt;setReturnReference('_createSocket', $socket);
+ $telnet-&gt;Telnet();
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ The partial mock is a subclass of the original with
+ selected methods "knocked out" with test
+ versions.
+ The <span class="new_code">generatePartial()</span> call
+ takes three parameters: the class to be subclassed,
+ the new test class name and a list of methods to mock.
+ </p>
+ <p>
+ Instantiating the resulting objects is slightly tricky.
+ The only constructor parameter of a partial mock is
+ the unit tester reference.
+ As with the normal mock objects this is needed for sending
+ test results in response to checked expectations.
+ </p>
+ <p>
+ The original constructor is not run yet.
+ This is necessary in case the constructor is going to
+ make use of the as yet unset mocked methods.
+ We set any return values at this point and then run the
+ constructor with its normal parameters.
+ This three step construction of "new", followed
+ by setting up the methods, followed by running the constructor
+ proper is what distinguishes the partial mock code.
+ </p>
+ <p>
+ Apart from construction, all of the mocked methods have
+ the same features as mock objects and all of the unmocked
+ methods behave as before.
+ We can set expectations very easily...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new TelnetTestVersion($this);
+ $telnet-&gt;setReturnReference('_createSocket', $socket);<strong>
+ $telnet-&gt;expectOnce('_createSocket', array('127.0.0.1', 21));</strong>
+ $telnet-&gt;Telnet();
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...<strong>
+ $telnet-&gt;tally();</strong>
+ }
+}
+</pre>
+ </p>
+
+ <p><a class="target" name="less"><h2>Testing less than a class</h2></a></p>
+ <p>
+ The mocked out methods don't have to be factory methods,
+ they could be any sort of method.
+ In this way partial mocks allow us to take control of any part of
+ a class except the constructor.
+ We could even go as far as to mock every method
+ except one we actually want to test.
+ </p>
+ <p>
+ This last situation is all rather hypothetical, as I haven't
+ tried it.
+ I am open to the possibility, but a little worried that
+ forcing object granularity may be better for the code quality.
+ I personally use partial mocks as a way of overriding creation
+ or for occasional testing of the TemplateMethod pattern.
+ </p>
+ <p>
+ It's all going to come down to the coding standards of your
+ project to decide which mechanism you use.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">Full API for SimpleTest</a>
+ from the PHPDoc.
+ </li>
+<li>
+ The protected factory is described in
+ <a href="http://www-106.ibm.com/developerworks/java/library/j-mocktest.html">this paper from IBM</a>.
+ This is the only formal comment I have seen on this problem.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <span class="chosen">Partial mocks</span>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/reporter_documentation.html b/vendors/simpletest/docs/en/reporter_documentation.html
new file mode 100644
index 000000000..87c89e44b
--- /dev/null
+++ b/vendors/simpletest/docs/en/reporter_documentation.html
@@ -0,0 +1,519 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>SimpleTest for PHP test runner and display documentation</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <span class="chosen">Reporting</span>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Test reporter documentation</h1>
+ This page...
+ <ul>
+<li>
+ Displaying <a href="#html">results in HTML</a>
+ </li>
+<li>
+ Displaying and <a href="#other">reporting results</a>
+ in other formats
+ </li>
+<li>
+ Using <a href="#cli">SimpleTest from the command line</a>
+ </li>
+<li>
+ Using <a href="#xml">Using XML</a> for remote testing
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ SimpleTest pretty much follows the MVC pattern
+ (Model-View-Controller).
+ The reporter classes are the view and the model is your
+ test cases and their hiearchy.
+ The controller is mostly hidden from the user of
+ SimpleTest unless you want to change how the test cases
+ are actually run, in which case it is possible to
+ override the runner objects from within the test case.
+ As usual with MVC, the controller is mostly undefined
+ and there are other places to control the test run.
+ </p>
+
+ <p><a class="target" name="html"><h2>Reporting results in HTML</h2></a></p>
+ <p>
+ The default test display is minimal in the extreme.
+ It reports success and failure with the conventional red and
+ green bars and shows a breadcrumb trail of test groups
+ for every failed assertion.
+ Here's a fail...
+ <div class="demo">
+ <h1>File test</h1>
+ <span class="fail">Fail</span>: createnewfile-&gt;True assertion failed.<br>
+ <div style="padding: 8px; margin-top: 1em; background-color: red; color: white;">1/1 test cases complete.
+ <strong>0</strong> passes, <strong>1</strong> fails and <strong>0</strong> exceptions.</div>
+ </div>
+ And here all tests passed...
+ <div class="demo">
+ <h1>File test</h1>
+ <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">1/1 test cases complete.
+ <strong>1</strong> passes, <strong>0</strong> fails and <strong>0</strong> exceptions.</div>
+ </div>
+ The good news is that there are several points in the display
+ hiearchy for subclassing.
+ </p>
+ <p>
+ For web page based displays there is the
+ <span class="new_code">HtmlReporter</span> class with the following
+ signature...
+<pre>
+class HtmlReporter extends SimpleReporter {
+ public HtmlReporter($encoding) { ... }
+ public makeDry(boolean $is_dry) { ... }
+ public void paintHeader(string $test_name) { ... }
+ public void sendNoCacheHeaders() { ... }
+ public void paintFooter(string $test_name) { ... }
+ public void paintGroupStart(string $test_name, integer $size) { ... }
+ public void paintGroupEnd(string $test_name) { ... }
+ public void paintCaseStart(string $test_name) { ... }
+ public void paintCaseEnd(string $test_name) { ... }
+ public void paintMethodStart(string $test_name) { ... }
+ public void paintMethodEnd(string $test_name) { ... }
+ public void paintFail(string $message) { ... }
+ public void paintPass(string $message) { ... }
+ public void paintError(string $message) { ... }
+ public void paintException(string $message) { ... }
+ public void paintMessage(string $message) { ... }
+ public void paintFormattedMessage(string $message) { ... }
+ protected string _getCss() { ... }
+ public array getTestList() { ... }
+ public integer getPassCount() { ... }
+ public integer getFailCount() { ... }
+ public integer getExceptionCount() { ... }
+ public integer getTestCaseCount() { ... }
+ public integer getTestCaseProgress() { ... }
+}
+</pre>
+ Here is what some of these methods mean. First the display methods
+ that you will probably want to override...
+ <ul class="api">
+ <li>
+ <span class="new_code">HtmlReporter(string $encoding)</span><br>
+ is the constructor.
+ Note that the unit test sets up the link to the display
+ rather than the other way around.
+ The display is a mostly passive receiver of test events.
+ This allows easy adaption of the display for other test
+ systems beside unit tests, such as monitoring servers.
+ The encoding is the character encoding you wish to
+ display the test output in.
+ In order to correctly render debug output when
+ using the web tester, this should match the encoding
+ of the site you are trying to test.
+ The available character set strings are described in
+ the PHP <a href="http://www.php.net/manual/en/function.htmlentities.php">html_entities()</a>
+ function.
+ </li>
+ <li>
+ <span class="new_code">void paintHeader(string $test_name)</span><br>
+ is called once at the very start of the test when the first
+ start event arrives.
+ The first start event is usually delivered by the top level group
+ test and so this is where <span class="new_code">$test_name</span>
+ comes from.
+ It paints the page titles, CSS, body tag, etc.
+ It returns nothing (<span class="new_code">void</span>).
+ </li>
+ <li>
+ <span class="new_code">void paintFooter(string $test_name)</span><br>
+ Called at the very end of the test to close any tags opened
+ by the page header.
+ By default it also displays the red/green bar and the final
+ count of results.
+ Actually the end of the test happens when a test end event
+ comes in with the same name as the one that started it all
+ at the same level.
+ The tests nest you see.
+ Closing the last test finishes the display.
+ </li>
+ <li>
+ <span class="new_code">void paintMethodStart(string $test_name)</span><br>
+ is called at the start of each test method.
+ The name normally comes from method name.
+ The other test start events behave the same way except
+ that the group test one tells the reporter how large
+ it is in number of held test cases.
+ This is so that the reporter can display a progress bar
+ as the runner churns through the test cases.
+ </li>
+ <li>
+ <span class="new_code">void paintMethodEnd(string $test_name)</span><br>
+ backs out of the test started with the same name.
+ </li>
+ <li>
+ <span class="new_code">void paintFail(string $message)</span><br>
+ paints a failure.
+ By default it just displays the word fail, a breadcrumbs trail
+ showing the current test nesting and the message issued by
+ the assertion.
+ </li>
+ <li>
+ <span class="new_code">void paintPass(string $message)</span><br>
+ by default does nothing.
+ </li>
+ <li>
+ <span class="new_code">string _getCss()</span><br>
+ Returns the CSS styles as a string for the page header
+ method.
+ Additional styles have to be appended here if you are
+ not overriding the page header.
+ You will want to use this method in an overriden page header
+ if you want to include the original CSS.
+ </li>
+ </ul>
+ There are also some accessors to get information on the current
+ state of the test suite.
+ Use these to enrich the display...
+ <ul class="api">
+ <li>
+ <span class="new_code">array getTestList()</span><br>
+ is the first convenience method for subclasses.
+ Lists the current nesting of the tests as a list
+ of test names.
+ The first, most deeply nested test, is first in the
+ list and the current test method will be last.
+ </li>
+ <li>
+ <span class="new_code">integer getPassCount()</span><br>
+ returns the number of passes chalked up so far.
+ Needed for the display at the end.
+ </li>
+ <li>
+ <span class="new_code">integer getFailCount()</span><br>
+ is likewise the number of fails so far.
+ </li>
+ <li>
+ <span class="new_code">integer getExceptionCount()</span><br>
+ is likewise the number of errors so far.
+ </li>
+ <li>
+ <span class="new_code">integer getTestCaseCount()</span><br>
+ is the total number of test cases in the test run.
+ This includes the grouping tests themselves.
+ </li>
+ <li>
+ <span class="new_code">integer getTestCaseProgress()</span><br>
+ is the number of test cases completed so far.
+ </li>
+ </ul>
+ One simple modification is to get the HtmlReporter to display
+ the passes as well as the failures and errors...
+<pre>
+<strong>class ShowPasses extends HtmlReporter {
+
+ function paintPass($message) {
+ parent::paintPass($message);
+ print "&amp;&lt;span class=\"pass\"&gt;Pass&lt;/span&gt;: ";
+ $breadcrumb = $this-&gt;getTestList();
+ array_shift($breadcrumb);
+ print implode("-&amp;gt;", $breadcrumb);
+ print "-&amp;gt;$message&lt;br /&gt;\n";
+ }
+
+ function _getCss() {
+ return parent::_getCss() . ' .pass { color: green; }';
+ }
+}</strong>
+</pre>
+ </p>
+ <p>
+ One method that was glossed over was the <span class="new_code">makeDry()</span>
+ method.
+ If you run this method, with no parameters, on the reporter
+ before the test suite is run no actual test methods
+ will be called.
+ You will still get the events of entering and leaving the
+ test methods and test cases, but no passes or failures etc,
+ because the test code will not actually be executed.
+ </p>
+ <p>
+ The reason for this is to allow for more sophistcated
+ GUI displays that allow the selection of individual test
+ cases.
+ In order to build a list of possible tests they need a
+ report on the test structure for drawing, say a tree view
+ of the test suite.
+ With a reporter set to dry run that just sends drawing events
+ this is easily accomplished.
+ </p>
+
+ <p><a class="target" name="other"><h2>Extending the reporter</h2></a></p>
+ <p>
+ Rather than simply modifying the existing display, you might want to
+ produce a whole new HTML look, or even generate text or XML.
+ Rather than override every method in
+ <span class="new_code">HtmlReporter</span> we can take one
+ step up the class hiearchy to <span class="new_code">SimpleReporter</span>
+ in the <em>simple_test.php</em> source file.
+ </p>
+ <p>
+ A do nothing display, a blank canvas for your own creation, would
+ be...
+<pre>
+<strong>require_once('simpletest/simple_test.php');</strong>
+
+class MyDisplay extends SimpleReporter {<strong>
+ </strong>
+ function paintHeader($test_name) {
+ }
+
+ function paintFooter($test_name) {
+ }
+
+ function paintStart($test_name, $size) {<strong>
+ parent::paintStart($test_name, $size);</strong>
+ }
+
+ function paintEnd($test_name, $size) {<strong>
+ parent::paintEnd($test_name, $size);</strong>
+ }
+
+ function paintPass($message) {<strong>
+ parent::paintPass($message);</strong>
+ }
+
+ function paintFail($message) {<strong>
+ parent::paintFail($message);</strong>
+ }
+}
+</pre>
+ No output would come from this class until you add it.
+ </p>
+
+ <p><a class="target" name="cli"><h2>The command line reporter</h2></a></p>
+ <p>
+ SimpleTest also ships with a minimal command line reporter.
+ The interface mimics JUnit to some extent, but paints the
+ failure messages as they arrive.
+ To use the command line reporter simply substitute it
+ for the HTML version...
+<pre>
+&lt;?php
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/reporter.php');
+
+$test = &amp;new TestSuite('File test');
+$test-&gt;addTestFile('tests/file_test.php');
+$test-&gt;run(<strong>new TextReporter()</strong>);
+?&gt;
+</pre>
+ Then invoke the test suite from the command line...
+<pre class="shell">
+php file_test.php
+</pre>
+ You will need the command line version of PHP installed
+ of course.
+ A passing test suite looks like this...
+<pre class="shell">
+File test
+OK
+Test cases run: 1/1, Failures: 0, Exceptions: 0
+</pre>
+ A failure triggers a display like this...
+<pre class="shell">
+File test
+1) True assertion failed.
+ in createnewfile
+FAILURES!!!
+Test cases run: 1/1, Failures: 1, Exceptions: 0
+</pre>
+ </p>
+ <p>
+ One of the main reasons for using a command line driven
+ test suite is of using the tester as part of some automated
+ process.
+ To function properly in shell scripts the test script should
+ return a non-zero exit code on failure.
+ If a test suite fails the value <span class="new_code">false</span>
+ is returned from the <span class="new_code">SimpleTest::run()</span>
+ method.
+ We can use that result to exit the script with the desired return
+ code...
+<pre>
+&lt;?php
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/reporter.php');
+
+$test = &amp;new TestSuite('File test');
+$test-&gt;addTestFile('tests/file_test.php');
+<strong>exit ($test-&gt;run(new TextReporter()) ? 0 : 1);</strong>
+?&gt;
+</pre>
+ Of course we don't really want to create two test scripts,
+ a command line one and a web browser one, for each test suite.
+ The command line reporter includes a method to sniff out the
+ run time environment...
+<pre>
+&lt;?php
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/reporter.php');
+
+$test = &amp;new TestSuite('File test');
+$test-&gt;addTestFile('tests/file_test.php');
+<strong>if (TextReporter::inCli()) {</strong>
+ exit ($test-&gt;run(new TextReporter()) ? 0 : 1);
+<strong>}</strong>
+$test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ This is the form used within SimpleTest itself.
+ </p>
+
+ <p><a class="target" name="xml"><h2>Remote testing</h2></a></p>
+ <p>
+ SimpleTest ships with an <span class="new_code">XmlReporter</span> class
+ used for internal communication.
+ When run the output looks like...
+<pre class="shell">
+&lt;?xml version="1.0"?&gt;
+&lt;run&gt;
+ &lt;group size="4"&gt;
+ &lt;name&gt;Remote tests&lt;/name&gt;
+ &lt;group size="4"&gt;
+ &lt;name&gt;Visual test with 48 passes, 48 fails and 4 exceptions&lt;/name&gt;
+ &lt;case&gt;
+ &lt;name&gt;testofunittestcaseoutput&lt;/name&gt;
+ &lt;test&gt;
+ &lt;name&gt;testofresults&lt;/name&gt;
+ &lt;pass&gt;This assertion passed&lt;/pass&gt;
+ &lt;fail&gt;This assertion failed&lt;/fail&gt;
+ &lt;/test&gt;
+ &lt;test&gt;
+ ...
+ &lt;/test&gt;
+ &lt;/case&gt;
+ &lt;/group&gt;
+ &lt;/group&gt;
+&lt;/run&gt;
+</pre>
+ You can make use of this format with the parser
+ supplied as part of SimpleTest itself.
+ This is called <span class="new_code">SimpleTestXmlParser</span> and
+ resides in <em>xml.php</em> within the SimpleTest package...
+<pre>
+&lt;?php
+require_once('simpletest/xml.php');
+
+...
+$parser = &amp;new SimpleTestXmlParser(new HtmlReporter());
+$parser-&gt;parse($test_output);
+?&gt;
+</pre>
+ The <span class="new_code">$test_output</span> should be the XML format
+ from the XML reporter, and could come from say a command
+ line run of a test case.
+ The parser sends events to the reporter just like any
+ other test run.
+ There are some odd occasions where this is actually useful.
+ </p>
+ <p>
+ A problem with large test suites is thet they can exhaust
+ the default 8Mb memory limit on a PHP process.
+ By having the test groups output in XML and run in
+ separate processes, the output can be reparsed to
+ aggregate the results into a much smaller footprint top level
+ test.
+ </p>
+ <p>
+ Because the XML output can come from anywhere, this opens
+ up the possibility of aggregating test runs from remote
+ servers.
+ A test case already exists to do this within the SimpleTest
+ framework, but it is currently experimental...
+<pre>
+&lt;?php
+<strong>require_once('../remote.php');</strong>
+require_once('../reporter.php');
+
+$test_url = ...;
+$dry_url = ...;
+
+$test = &amp;new TestSuite('Remote tests');
+$test-&gt;addTestCase(<strong>new RemoteTestCase($test_url, $dry_url)</strong>);
+$test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ The <span class="new_code">RemoteTestCase</span> takes the actual location
+ of the test runner, basically a web page in XML format.
+ It also takes the URL of a reporter set to do a dry run.
+ This is so that progress can be reported upward correctly.
+ The <span class="new_code">RemoteTestCase</span> can be added to test suites
+ just like any other group test.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
+ gives full detail on the classes and assertions available.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <span class="chosen">Reporting</span>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/unit_test_documentation.html b/vendors/simpletest/docs/en/unit_test_documentation.html
new file mode 100644
index 000000000..bc43c82cc
--- /dev/null
+++ b/vendors/simpletest/docs/en/unit_test_documentation.html
@@ -0,0 +1,431 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>SimpleTest for PHP regression test documentation</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <span class="chosen">Unit tester</span>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>PHP Unit Test documentation</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#unit">Unit test cases</a> and basic assertions.
+ </li>
+<li>
+ <a href="#extending_unit">Extending test cases</a> to
+ customise them for your own project.
+ </li>
+<li>
+ <a href="#running_unit">Running a single case</a> as
+ a single script.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="unit"><h2>Unit test cases</h2></a></p>
+ <p>
+ The core system is a regression testing framework built around
+ test cases.
+ A sample test case looks like this...
+<pre>
+<strong>class FileTestCase extends UnitTestCase {
+}</strong>
+</pre>
+ Actual tests are added as methods in the test case whose names
+ by default start with the string "test" and
+ when the test case is invoked all such methods are run in
+ the order that PHP introspection finds them.
+ As many test methods can be added as needed.
+ </p>
+ <p>
+ For example...
+<pre>
+require_once('simpletest/autorun.php');
+require_once('../classes/writer.php');
+
+class FileTestCase extends UnitTestCase {
+ function FileTestCase() {
+ $this-&gt;UnitTestCase('File test');
+ }<strong>
+
+ function setUp() {
+ @unlink('../temp/test.txt');
+ }
+
+ function tearDown() {
+ @unlink('../temp/test.txt');
+ }
+
+ function testCreation() {
+ $writer = &amp;new FileWriter('../temp/test.txt');
+ $writer-&gt;write('Hello');
+ $this-&gt;assertTrue(file_exists('../temp/test.txt'), 'File created');
+ }</strong>
+}
+</pre>
+ The constructor is optional and usually omitted.
+ Without a name, the class name is taken as the name of the test case.
+ </p>
+ <p>
+ Our only test method at the moment is <span class="new_code">testCreation()</span>
+ where we check that a file has been created by our
+ <span class="new_code">Writer</span> object.
+ We could have put the <span class="new_code">unlink()</span>
+ code into this method as well, but by placing it in
+ <span class="new_code">setUp()</span> and
+ <span class="new_code">tearDown()</span> we can use it with
+ other test methods that we add.
+ </p>
+ <p>
+ The <span class="new_code">setUp()</span> method is run
+ just before each and every test method.
+ <span class="new_code">tearDown()</span> is run just after
+ each and every test method.
+ </p>
+ <p>
+ You can place some test case set up into the constructor to
+ be run once for all the methods in the test case, but
+ you risk test inteference that way.
+ This way is slightly slower, but it is safer.
+ Note that if you come from a JUnit background this will not
+ be the behaviour you are used to.
+ JUnit surprisingly reinstantiates the test case for each test
+ method to prevent such interference.
+ SimpleTest requires the end user to use <span class="new_code">setUp()</span>, but
+ supplies additional hooks for library writers.
+ </p>
+ <p>
+ The means of reporting test results (see below) are by a
+ visiting display class
+ that is notified by various <span class="new_code">assert...()</span>
+ methods.
+ Here is the full list for the <span class="new_code">UnitTestCase</span>
+ class, the default for SimpleTest...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">assertTrue($x)</span></td>
+<td>Fail if $x is false</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertFalse($x)</span></td>
+<td>Fail if $x is true</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNull($x)</span></td>
+<td>Fail if $x is set</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNotNull($x)</span></td>
+<td>Fail if $x not set</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertIsA($x, $t)</span></td>
+<td>Fail if $x is not the class or type $t</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNotA($x, $t)</span></td>
+<td>Fail if $x is of the class or type $t</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertEqual($x, $y)</span></td>
+<td>Fail if $x == $y is false</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNotEqual($x, $y)</span></td>
+<td>Fail if $x == $y is true</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertWithinMargin($x, $y, $m)</span></td>
+<td>Fail if abs($x - $y) &lt; $m is false</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertOutsideMargin($x, $y, $m)</span></td>
+<td>Fail if abs($x - $y) &lt; $m is true</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertIdentical($x, $y)</span></td>
+<td>Fail if $x == $y is false or a type mismatch</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNotIdentical($x, $y)</span></td>
+<td>Fail if $x == $y is true and types match</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertReference($x, $y)</span></td>
+<td>Fail unless $x and $y are the same variable</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertClone($x, $y)</span></td>
+<td>Fail unless $x and $y are identical copies</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertPattern($p, $x)</span></td>
+<td>Fail unless the regex $p matches $x</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoPattern($p, $x)</span></td>
+<td>Fail if the regex $p matches $x</td>
+</tr>
+ <tr>
+<td><span class="new_code">expectError($x)</span></td>
+<td>Swallows any upcoming matching error</td>
+</tr>
+ <tr>
+<td><span class="new_code">assert($e)</span></td>
+<td>Fail on failed <a href="expectation_documentation.html">expectation</a> object $e</td>
+</tr>
+ </tbody></table>
+ All assertion methods can take an optional description as a
+ last parameter.
+ This is to label the displayed result with.
+ If omitted a default message is sent instead, which is usually
+ sufficient.
+ This default message can still be embedded in your own message
+ if you include "%s" within the string.
+ All the assertions return true on a pass or false on failure.
+ </p>
+ <p>
+ Some examples...
+<pre>
+$variable = null;
+<strong>$this-&gt;assertNull($variable, 'Should be cleared');</strong>
+</pre>
+ ...will pass and normally show no message.
+ If you have
+ <a href="http://www.lastcraft.com/display_subclass_tutorial.php">set up the tester to display passes</a>
+ as well then the message will be displayed as is.
+<pre>
+<strong>$this-&gt;assertIdentical(0, false, 'Zero is not false [%s]');</strong>
+</pre>
+ This will fail as it performs a type
+ check, as well as a comparison, between the two values.
+ The "%s" part is replaced by the default
+ error message that would have been shown if we had not
+ supplied our own.
+<pre>
+$a = 1;
+$b = $a;
+<strong>$this-&gt;assertReference($a, $b);</strong>
+</pre>
+ Will fail as the variable <span class="new_code">$a</span> is a copy of <span class="new_code">$b</span>.
+<pre>
+<strong>$this-&gt;assertPattern('/hello/i', 'Hello world');</strong>
+</pre>
+ This will pass as using a case insensitive match the string
+ <span class="new_code">hello</span> is contained in <span class="new_code">Hello world</span>.
+<pre>
+<strong>$this-&gt;expectError();</strong>
+trigger_error('Catastrophe');
+</pre>
+ Here the check catches the "Catastrophe"
+ message without checking the text and passes.
+ This removes the error from the queue.
+<pre>
+<strong>$this-&gt;expectError('Catastrophe');</strong>
+trigger_error('Catastrophe');
+</pre>
+ The next error check tests not only the existence of the error,
+ but also the text which, here matches so another pass.
+ If any unchecked errors are left at the end of a test method then
+ an exception will be reported in the test.
+ </p>
+ <p>
+ Note that SimpleTest cannot catch compile time PHP errors.
+ </p>
+ <p>
+ The test cases also have some convenience methods for debugging
+ code or extending the suite...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">setUp()</span></td>
+<td>Runs this before each test method</td>
+</tr>
+ <tr>
+<td><span class="new_code">tearDown()</span></td>
+<td>Runs this after each test method</td>
+</tr>
+ <tr>
+<td><span class="new_code">pass()</span></td>
+<td>Sends a test pass</td>
+</tr>
+ <tr>
+<td><span class="new_code">fail()</span></td>
+<td>Sends a test failure</td>
+</tr>
+ <tr>
+<td><span class="new_code">error()</span></td>
+<td>Sends an exception event</td>
+</tr>
+ <tr>
+<td><span class="new_code">signal($type, $payload)</span></td>
+<td>Sends a user defined message to the test reporter</td>
+</tr>
+ <tr>
+<td><span class="new_code">dump($var)</span></td>
+<td>Does a formatted <span class="new_code">print_r()</span> for quick and dirty debugging</td>
+</tr>
+ </tbody></table>
+ </p>
+
+ <p><a class="target" name="extending_unit"><h2>Extending test cases</h2></a></p>
+ <p>
+ Of course additional test methods can be added to create
+ specific types of test case, so as to extend framework...
+<pre>
+require_once('simpletest/autorun.php');
+<strong>
+class FileTester extends UnitTestCase {
+ function FileTester($name = false) {
+ $this-&gt;UnitTestCase($name);
+ }
+
+ function assertFileExists($filename, $message = '%s') {
+ $this-&gt;assertTrue(
+ file_exists($filename),
+ sprintf($message, 'File [$filename] existence check'));
+ }</strong>
+}
+</pre>
+ Here the SimpleTest library is held in a folder called
+ <em>simpletest</em> that is local.
+ Substitute your own path for this.
+ </p>
+ <p>
+ To prevent this test case being run accidently, it is
+ advisable to mark it as <span class="new_code">abstract</span>.
+ </p>
+ <p>
+ Alternatively you could add a
+ <span class="new_code">SimpleTestOptions::ignore('FileTester');</span>
+ directive in your code.
+ </p>
+ <p>
+ This new case can be now be inherited just like
+ a normal test case...
+<pre>
+class FileTestCase extends <strong>FileTester</strong> {
+
+ function setUp() {
+ @unlink('../temp/test.txt');
+ }
+
+ function tearDown() {
+ @unlink('../temp/test.txt');
+ }
+
+ function testCreation() {
+ $writer = &amp;new FileWriter('../temp/test.txt');
+ $writer-&gt;write('Hello');<strong>
+ $this-&gt;assertFileExists('../temp/test.txt');</strong>
+ }
+}
+</pre>
+ </p>
+ <p>
+ If you want a test case that does not have all of the
+ <span class="new_code">UnitTestCase</span> assertions,
+ only your own and a few basics,
+ you need to extend the <span class="new_code">SimpleTestCase</span>
+ class instead.
+ It is found in <em>simple_test.php</em> rather than
+ <em>unit_tester.php</em>.
+ See <a href="group_test_documentation.html">later</a> if you
+ want to incorporate other unit tester's
+ test cases in your test suites.
+ </p>
+
+ <p><a class="target" name="running_unit"><h2>Running a single test case</h2></a></p>
+ <p>
+ You won't often run single test cases except when bashing
+ away at a module that is having difficulty, and you don't
+ want to upset the main test suite.
+ With <em>autorun</em> no particular scaffolding is needed,
+ just launch your particular test file and you're ready to go.
+ </p>
+ <p>
+ You can even decide which reporter (for example,
+ <span class="new_code">TextReporter</span> or <span class="new_code">HtmlReporter</span>)
+ you prefer for a specific file when launched on its own...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');<strong>
+SimpleTest :: prefer(new TextReporter());</strong>
+require_once('../classes/writer.php');
+
+class FileTestCase extends UnitTestCase {
+ ...
+}
+?&gt;
+</pre>
+ This script will run as is, but of course will output zero passes
+ and zero failures until test methods are added.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">Full API for SimpleTest</a>
+ from the PHPDoc.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <span class="chosen">Unit tester</span>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/en/web_tester_documentation.html b/vendors/simpletest/docs/en/web_tester_documentation.html
new file mode 100644
index 000000000..2602dd56d
--- /dev/null
+++ b/vendors/simpletest/docs/en/web_tester_documentation.html
@@ -0,0 +1,584 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Simple Test for PHP web script testing documentation</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <span class="chosen">Web tester</span>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Web tester documentation</h1>
+ This page...
+ <ul>
+<li>
+ Successfully <a href="#fetch">fetching a web page</a>
+ </li>
+<li>
+ Testing the <a href="#content">page content</a>
+ </li>
+<li>
+ <a href="#navigation">Navigating a web site</a>
+ while testing
+ </li>
+<li>
+ <a href="#request">Raw request modifications</a> and debugging methods
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="fetch"><h2>Fetching a page</h2></a></p>
+ <p>
+ Testing classes is all very well, but PHP is predominately
+ a language for creating functionality within web pages.
+ How do we test the front end presentation role of our PHP
+ applications?
+ Well the web pages are just text, so we should be able to
+ examine them just like any other test data.
+ </p>
+ <p>
+ This leads to a tricky issue.
+ If we test at too low a level, testing for matching tags
+ in the page with pattern matching for example, our tests will
+ be brittle.
+ The slightest change in layout could break a large number of
+ tests.
+ If we test at too high a level, say using mock versions of a
+ template engine, then we lose the ability to automate some classes
+ of test.
+ For example, the interaction of forms and navigation will
+ have to be tested manually.
+ These types of test are extremely repetitive and error prone.
+ </p>
+ <p>
+ SimpleTest includes a special form of test case for the testing
+ of web page actions.
+ The <span class="new_code">WebTestCase</span> includes facilities
+ for navigation, content and cookie checks and form handling.
+ Usage of these test cases is similar to the
+ <a href="unit_tester_documentation.html">UnitTestCase</a>...
+<pre>
+<strong>class TestOfLastcraft extends WebTestCase {
+}</strong>
+</pre>
+ Here we are about to test the
+ <a href="http://www.lastcraft.com/">Last Craft</a> site itself.
+ If this test case is in a file called <em>lastcraft_test.php</em>
+ then it can be loaded in a runner script just like unit tests...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');<strong>
+require_once('simpletest/web_tester.php');</strong>
+SimpleTest::prefer(new TextReporter());
+
+class WebTests extends TestSuite {
+ function WebTests() {
+ $this-&gt;TestSuite('Web site tests');<strong>
+ $this-&gt;addFile('lastcraft_test.php');</strong>
+ }
+}
+?&gt;
+</pre>
+ I am using the text reporter here to more clearly
+ distinguish the web content from the test output.
+ </p>
+ <p>
+ Nothing is being tested yet.
+ We can fetch the home page by using the
+ <span class="new_code">get()</span> method...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+ <strong>
+ function testHomepage() {
+ $this-&gt;assertTrue($this-&gt;get('http://www.lastcraft.com/'));
+ }</strong>
+}
+</pre>
+ The <span class="new_code">get()</span> method will
+ return true only if page content was successfully
+ loaded.
+ It is a simple, but crude way to check that a web page
+ was actually delivered by the web server.
+ However that content may be a 404 response and yet
+ our <span class="new_code">get()</span> method will still return true.
+ </p>
+ <p>
+ Assuming that the web server for the Last Craft site is up
+ (sadly not always the case), we should see...
+<pre class="shell">
+Web site tests
+OK
+Test cases run: 1/1, Failures: 0, Exceptions: 0
+</pre>
+ All we have really checked is that any kind of page was
+ returned.
+ We don't yet know if it was the right one.
+ </p>
+
+ <p><a class="target" name="content"><h2>Testing page content</h2></a></p>
+ <p>
+ To confirm that the page we think we are on is actually the
+ page we are on, we need to verify the page content.
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testHomepage() {<strong>
+ $this-&gt;get('http://www.lastcraft.com/');
+ $this-&gt;assertText('Why the last craft');</strong>
+ }
+}
+</pre>
+ The page from the last fetch is held in a buffer in
+ the test case, so there is no need to refer to it directly.
+ The pattern match is always made against the buffer.
+ </p>
+ <p>
+ Here is the list of possible content assertions...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">assertTitle($title)</span></td>
+<td>Pass if title is an exact match</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertText($text)</span></td>
+<td>Pass if matches visible and "alt" text</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoText($text)</span></td>
+<td>Pass if doesn't match visible and "alt" text</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertPattern($pattern)</span></td>
+<td>A Perl pattern match against the page content</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoPattern($pattern)</span></td>
+<td>A Perl pattern match to not find content</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertLink($label)</span></td>
+<td>Pass if a link with this text is present</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoLink($label)</span></td>
+<td>Pass if no link with this text is present</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertLinkById($id)</span></td>
+<td>Pass if a link with this id attribute is present</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoLinkById($id)</span></td>
+<td>Pass if no link with this id attribute is present</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertField($name, $value)</span></td>
+<td>Pass if an input tag with this name has this value</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertFieldById($id, $value)</span></td>
+<td>Pass if an input tag with this id has this value</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertResponse($codes)</span></td>
+<td>Pass if HTTP response matches this list</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertMime($types)</span></td>
+<td>Pass if MIME type is in this list</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertAuthentication($protocol)</span></td>
+<td>Pass if the current challenge is this protocol</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoAuthentication()</span></td>
+<td>Pass if there is no current challenge</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertRealm($name)</span></td>
+<td>Pass if the current challenge realm matches</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertHeader($header, $content)</span></td>
+<td>Pass if a header was fetched matching this value</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoHeader($header)</span></td>
+<td>Pass if a header was not fetched</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertCookie($name, $value)</span></td>
+<td>Pass if there is currently a matching cookie</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoCookie($name)</span></td>
+<td>Pass if there is currently no cookie of this name</td>
+</tr>
+ </tbody></table>
+ As usual with the SimpleTest assertions, they all return
+ false on failure and true on pass.
+ They also allow an optional test message and you can embed
+ the original test message inside using "%s" inside
+ your custom message.
+ </p>
+ <p>
+ So now we could instead test against the title tag with...
+<pre>
+<strong>$this-&gt;assertTitle('The Last Craft? Web developer tutorials on PHP, Extreme programming and Object Oriented development');</strong>
+</pre>
+ ...or, if that is too long and fragile...
+<pre>
+<strong>$this-&gt;assertTitle(new PatternExpectation('/The Last Craft/'));</strong>
+</pre>
+ As well as the simple HTML content checks we can check
+ that the MIME type is in a list of allowed types with...
+<pre>
+<strong>$this-&gt;assertMime(array('text/plain', 'text/html'));</strong>
+</pre>
+ More interesting is checking the HTTP response code.
+ Like the MIME type, we can assert that the response code
+ is in a list of allowed values...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testRedirects() {
+ $this-&gt;get('http://www.lastcraft.com/test/redirect.php');
+ $this-&gt;assertResponse(200);&lt;/strong&gt;
+ }
+}
+</pre>
+ Here we are checking that the fetch is successful by
+ allowing only a 200 HTTP response.
+ This test will pass, but it is not actually correct to do so.
+ There is no page, instead the server issues a redirect.
+ The <span class="new_code">WebTestCase</span> will
+ automatically follow up to three such redirects.
+ The tests are more robust this way and we are usually
+ interested in the interaction with the pages rather
+ than their delivery.
+ If the redirects are of interest then this ability must
+ be disabled...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testHomepage() {<strong>
+ $this-&gt;setMaximumRedirects(0);</strong>
+ $this-&gt;get('http://www.lastcraft.com/test/redirect.php');
+ $this-&gt;assertResponse(200);
+ }
+}
+</pre>
+ The assertion now fails as expected...
+<pre class="shell">
+Web site tests
+1) Expecting response in [200] got [302]
+ in testhomepage
+ in testoflastcraft
+ in lastcraft_test.php
+FAILURES!!!
+Test cases run: 1/1, Failures: 1, Exceptions: 0
+</pre>
+ We can modify the test to correctly assert redirects with...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testHomepage() {
+ $this-&gt;setMaximumRedirects(0);
+ $this-&gt;get('http://www.lastcraft.com/test/redirect.php');
+ $this-&gt;assertResponse(<strong>array(301, 302, 303, 307)</strong>);
+ }
+}
+</pre>
+ This now passes.
+ </p>
+
+ <p><a class="target" name="navigation"><h2>Navigating a web site</h2></a></p>
+ <p>
+ Users don't often navigate sites by typing in URLs, but by
+ clicking links and buttons.
+ Here we confirm that the contact details can be reached
+ from the home page...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+ ...
+ function testContact() {
+ $this-&gt;get('http://www.lastcraft.com/');<strong>
+ $this-&gt;clickLink('About');
+ $this-&gt;assertTitle(new PatternExpectation('/About Last Craft/'));</strong>
+ }
+}
+</pre>
+ The parameter is the text of the link.
+ </p>
+ <p>
+ If the target is a button rather than an anchor tag, then
+ <span class="new_code">clickSubmit()</span> can be used
+ with the button title...
+<pre>
+<strong>$this-&gt;clickSubmit('Go!');</strong>
+</pre>
+ If you are not sure or don't care, the usual case, then just
+ use the <span class="new_code">click()</span> method...
+<pre>
+<strong>$this-&gt;click('Go!');</strong>
+</pre>
+ </p>
+ <p>
+ The list of navigation methods is...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">getUrl()</span></td>
+<td>The current location</td>
+</tr>
+ <tr>
+<td><span class="new_code">get($url, $parameters)</span></td>
+<td>Send a GET request with these parameters</td>
+</tr>
+ <tr>
+<td><span class="new_code">post($url, $parameters)</span></td>
+<td>Send a POST request with these parameters</td>
+</tr>
+ <tr>
+<td><span class="new_code">head($url, $parameters)</span></td>
+<td>Send a HEAD request without replacing the page content</td>
+</tr>
+ <tr>
+<td><span class="new_code">retry()</span></td>
+<td>Reload the last request</td>
+</tr>
+ <tr>
+<td><span class="new_code">back()</span></td>
+<td>Like the browser back button</td>
+</tr>
+ <tr>
+<td><span class="new_code">forward()</span></td>
+<td>Like the browser forward button</td>
+</tr>
+ <tr>
+<td><span class="new_code">authenticate($name, $password)</span></td>
+<td>Retry after a challenge</td>
+</tr>
+ <tr>
+<td><span class="new_code">restart()</span></td>
+<td>Restarts the browser as if a new session</td>
+</tr>
+ <tr>
+<td><span class="new_code">getCookie($name)</span></td>
+<td>Gets the cookie value for the current context</td>
+</tr>
+ <tr>
+<td><span class="new_code">ageCookies($interval)</span></td>
+<td>Ages current cookies prior to a restart</td>
+</tr>
+ <tr>
+<td><span class="new_code">clearFrameFocus()</span></td>
+<td>Go back to treating all frames as one page</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmit($label)</span></td>
+<td>Click the first button with this label</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitByName($name)</span></td>
+<td>Click the button with this name attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitById($id)</span></td>
+<td>Click the button with this ID attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImage($label, $x, $y)</span></td>
+<td>Click an input tag of type image by title or alt text</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageByName($name, $x, $y)</span></td>
+<td>Click an input tag of type image by name</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageById($id, $x, $y)</span></td>
+<td>Click an input tag of type image by ID attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">submitFormById($id)</span></td>
+<td>Submit a form without the submit value</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLink($label, $index)</span></td>
+<td>Click an anchor by the visible label text</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLinkById($id)</span></td>
+<td>Click an anchor by the ID attribute</td>
+</tr>
+ <tr>
+<td><span class="new_code">getFrameFocus()</span></td>
+<td>The name of the currently selected frame</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocusByIndex($choice)</span></td>
+<td>Focus on a frame counting from 1</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocus($name)</span></td>
+<td>Focus on a frame by name</td>
+</tr>
+ </tbody></table>
+ </p>
+ <p>
+ The parameters in the <span class="new_code">get()</span>, <span class="new_code">post()</span> or
+ <span class="new_code">head()</span> methods are optional.
+ The HTTP HEAD fetch does not change the browser context, only loads
+ cookies.
+ This can be useful for when an image or stylesheet sets a cookie
+ for crafty robot blocking.
+ </p>
+ <p>
+ The <span class="new_code">retry()</span>, <span class="new_code">back()</span> and
+ <span class="new_code">forward()</span> commands work as they would on
+ your web browser.
+ They use the history to retry pages.
+ This can be handy for checking the effect of hitting the
+ back button on your forms.
+ </p>
+ <p>
+ The frame methods need a little explanation.
+ By default a framed page is treated just like any other.
+ Content will be searced for throughout the entire frameset,
+ so clicking a link will work no matter which frame
+ the anchor tag is in.
+ You can override this behaviour by focusing on a single
+ frame.
+ If you do that, all searches and actions will apply to that
+ frame alone, such as authentication and retries.
+ If a link or button is not in a focused frame then it cannot
+ be clicked.
+ </p>
+ <p>
+ Testing navigation on fixed pages only tells you when you
+ have broken an entire script.
+ For highly dynamic pages, such as for bulletin boards, this can
+ be crucial for verifying the correctness of the application.
+ For most applications though, the really tricky logic is usually in
+ the handling of forms and sessions.
+ Fortunately SimpleTest includes
+ <a href="form_testing_documentation.html">tools for testing web forms</a>
+ as well.
+ </p>
+
+ <p><a class="target" name="request"><h2>Modifying the request</h2></a></p>
+ <p>
+ Although SimpleTest does not have the goal of testing networking
+ problems, it does include some methods to modify and debug
+ the requests it makes.
+ Here is another method list...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">getTransportError()</span></td>
+<td>The last socket error</td>
+</tr>
+ <tr>
+<td><span class="new_code">showRequest()</span></td>
+<td>Dump the outgoing request</td>
+</tr>
+ <tr>
+<td><span class="new_code">showHeaders()</span></td>
+<td>Dump the incoming headers</td>
+</tr>
+ <tr>
+<td><span class="new_code">showSource()</span></td>
+<td>Dump the raw HTML page content</td>
+</tr>
+ <tr>
+<td><span class="new_code">ignoreFrames()</span></td>
+<td>Do not load framesets</td>
+</tr>
+ <tr>
+<td><span class="new_code">setCookie($name, $value)</span></td>
+<td>Set a cookie from now on</td>
+</tr>
+ <tr>
+<td><span class="new_code">addHeader($header)</span></td>
+<td>Always add this header to the request</td>
+</tr>
+ <tr>
+<td><span class="new_code">setMaximumRedirects($max)</span></td>
+<td>Stop after this many redirects</td>
+</tr>
+ <tr>
+<td><span class="new_code">setConnectionTimeout($timeout)</span></td>
+<td>Kill the connection after this time between bytes</td>
+</tr>
+ <tr>
+<td><span class="new_code">useProxy($proxy, $name, $password)</span></td>
+<td>Make requests via this proxy URL</td>
+</tr>
+ </tbody></table>
+ These methods are principally for debugging.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ SimpleTest project page on <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ SimpleTest download page on <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ The <a href="http://simpletest.org/api/">developer's API for SimpleTest</a>
+ gives full detail on the classes and assertions available.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <span class="chosen">Web tester</span>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/authentication_documentation.html b/vendors/simpletest/docs/fr/authentication_documentation.html
new file mode 100644
index 000000000..782a46b12
--- /dev/null
+++ b/vendors/simpletest/docs/fr/authentication_documentation.html
@@ -0,0 +1,332 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation Simple Test : tester l'authentification</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur l'authentification</h1>
+ This page...
+ <ul>
+<li>
+ Passer au travers d'une <a href="#basique">authentification HTTP basique</a>
+ </li>
+<li>
+ Tester l'<a href="#cookies">authentification basée sur des cookies</a>
+ </li>
+<li>
+ Gérer les <a href="#session">sessions du navigateur</a> et les timeouts
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ Un des secteurs à la fois délicat et important lors d'un test
+ de site web reste la sécurité. Tester ces schémas est au coeur
+ des objectifs du testeur web de SimpleTest.
+ </p>
+
+ <p><a class="target" name="basique"><h2>Authentification HTTP basique</h2></a></p>
+ <p>
+ Si vous allez chercher une page web protégée
+ par une authentification basique, vous hériterez d'une entête 401.
+ Nous pouvons représenter ceci par ce test...
+<pre>
+class AuthenticationTest extends WebTestCase {<strong>
+ function test401Header() {
+ $this-&gt;get('http://www.lastcraft.com/protected/');
+ $this-&gt;showHeaders();
+ }</strong>
+}
+</pre>
+ Ce qui nous permet de voir les entêtes reçues...
+ <div class="demo">
+ <h1>File test</h1>
+<pre style="background-color: lightgray; color: black">
+HTTP/1.1 401 Authorization Required
+Date: Sat, 18 Sep 2004 19:25:18 GMT
+Server: Apache/1.3.29 (Unix) PHP/4.3.4
+WWW-Authenticate: Basic realm="SimpleTest basic authentication"
+Connection: close
+Content-Type: text/html; charset=iso-8859-1
+</pre>
+ <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">1/1 test cases complete.
+ <strong>0</strong> passes, <strong>0</strong> fails and <strong>0</strong> exceptions.</div>
+ </div>
+ Sauf que nous voulons éviter l'inspection visuelle,
+ on souhaite que SimpleTest puisse nous dire si oui ou non
+ la page est protégée. Voici un test en profondeur sur nos entêtes...
+<pre>
+class AuthenticationTest extends WebTestCase {
+ function test401Header() {
+ $this-&gt;get('http://www.lastcraft.com/protected/');<strong>
+ $this-&gt;assertAuthentication('Basic');
+ $this-&gt;assertResponse(401);
+ $this-&gt;assertRealm('SimpleTest basic authentication');</strong>
+ }
+}
+</pre>
+ N'importe laquelle de ces assertions suffirait,
+ tout dépend de la masse de détails que vous souhaitez voir.
+ </p>
+ <p>
+ La plupart du temps, nous ne souhaitons pas tester
+ l'authentification en elle-même, mais plutôt
+ les pages protégées par cette authentification.
+ Dès que la tentative d'authentification est reçue,
+ nous pouvons y répondre à l'aide d'une réponse d'authentification :
+<pre>
+class AuthenticationTest extends WebTestCase {
+ function testAuthentication() {
+ $this-&gt;get('http://www.lastcraft.com/protected/');<strong>
+ $this-&gt;authenticate('Me', 'Secret');</strong>
+ $this-&gt;assertTitle(...);
+ }
+}
+</pre>
+ Le nom d'utilisateur et le mot de passe seront désormais
+ envoyés à chaque requête vers ce répertoire
+ et ses sous-répertoires.
+ En revanche vous devrez vous authentifier à nouveau
+ si vous sortez de ce répertoire mais SimpleTest est assez
+ intelligent pour fusionner les sous-répertoires dans un même domaine.
+ </p>
+ <p>
+ Vous pouvez gagner une ligne en définissant
+ l'authentification au niveau de l'URL...
+<pre>
+class AuthenticationTest extends WebTestCase {
+ function testCanReadAuthenticatedPages() {
+ $this-&gt;get('http://<strong>Me:Secret@</strong>www.lastcraft.com/protected/');
+ $this-&gt;assertTitle(...);
+ }
+}
+</pre>
+ Si votre nom d'utilisateur ou mot de passe comporte
+ des caractères spéciaux, alors n'oubliez pas de les encoder,
+ sinon la requête ne sera pas analysée correctement.
+ De plus cette entête ne sera pas envoyée aux
+ sous requêtes si vous la définissez avec une URL absolue.
+ Par contre si vous naviguez avec des URL relatives,
+ l'information d'authentification sera préservée.
+ </p>
+ <p>
+ Pour l'instant, seule l'authentification de base est implémentée
+ et elle n'est réellement fiable qu'en tandem avec une connexion HTTPS.
+ C'est généralement suffisant pour protéger
+ le serveur testé des regards malveillants.
+ Les authentifications Digest et NTLM pourraient être ajoutées prochainement.
+ </p>
+
+ <p><a class="target" name="cookies"><h2>Cookies</h2></a></p>
+ <p>
+ L'authentification de base ne donne pas assez de contrôle
+ au développeur Web sur l'interface utilisateur.
+ Il y a de forte chance pour que cette fonctionnalité
+ soit codée directement dans l'architecture web
+ à grand renfort de cookies et de timeouts compliqués.
+ </p>
+ <p>
+ Commençons par un simple formulaire de connexion...
+<pre>
+&lt;form&gt;
+ Username:
+ &lt;input type="text" name="u" value="" /&gt;&lt;br /&gt;
+ Password:
+ &lt;input type="password" name="p" value="" /&gt;&lt;br /&gt;
+ &lt;input type="submit" value="Log in" /&gt;
+&lt;/form&gt;
+</pre>
+ Lequel doit ressembler à...
+ </p>
+ <p>
+ <form class="demo">
+ Username:
+ <input type="text" name="u" value=""><br>
+ Password:
+ <input type="password" name="p" value=""><br>
+ <input type="submit" value="Log in">
+ </form>
+ </p>
+ <p>
+ Supposons que, durant le chargement de la page,
+ un cookie ait été inscrit avec un numéro d'identifiant de session.
+ Nous n'allons pas encore remplir le formulaire,
+ juste tester que nous pistons bien l'utilisateur.
+ Voici le test...
+<pre>
+class LogInTest extends WebTestCase {
+ function testSessionCookieSetBeforeForm() {
+ $this-&gt;get('http://www.my-site.com/login.php');<strong>
+ $this-&gt;assertCookie('SID');</strong>
+ }
+}
+</pre>
+ Nous nous contentons ici de vérifier que le cookie a bien été défini.
+ Etant donné que sa valeur est plutôt énigmatique,
+ elle ne vaut pas la peine d'être testée.
+ </p>
+ <p>
+ Le reste du test est le même que dans n'importe quel autre formulaire,
+ mais nous pourrions souhaiter nous assurer
+ que le cookie n'a pas été modifié depuis la phase de connexion.
+ Voici comment cela pourrait être testé :
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testSessionCookieSameAfterLogIn() {
+ $this-&gt;get('http://www.my-site.com/login.php');<strong>
+ $session = $this-&gt;getCookie('SID');
+ $this-&gt;setField('u', 'Me');
+ $this-&gt;setField('p', 'Secret');
+ $this-&gt;clickSubmit('Log in');
+ $this-&gt;assertWantedPattern('/Welcome Me/');
+ $this-&gt;assertCookie('SID', $session);</strong>
+ }
+}
+</pre>
+ Ceci confirme que l'identifiant de session
+ est identique avant et après la connexion.
+ </p>
+ <p>
+ Nous pouvons même essayer de duper notre propre système
+ en créant un cookie arbitraire pour se connecter...
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testSessionCookieSameAfterLogIn() {
+ $this-&gt;get('http://www.my-site.com/login.php');<strong>
+ $this-&gt;setCookie('SID', 'Some other session');
+ $this-&gt;get('http://www.my-site.com/restricted.php');</strong>
+ $this-&gt;assertWantedPattern('/Access denied/');
+ }
+}
+</pre>
+ Votre site est-il protégé contre ce type d'attaque ?
+ </p>
+
+ <p><a class="target" name="session"><h2>Sessions de navigateur</h2></a></p>
+ <p>
+ Si vous testez un système d'authentification,
+ la reconnexion par un utilisateur est un point sensible.
+ Essayons de simuler ce qui se passe dans ce cas :
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testLoseAuthenticationAfterBrowserClose() {
+ $this-&gt;get('http://www.my-site.com/login.php');
+ $this-&gt;setField('u', 'Me');
+ $this-&gt;setField('p', 'Secret');
+ $this-&gt;clickSubmit('Log in');
+ $this-&gt;assertWantedPattern('/Welcome Me/');<strong>
+
+ $this-&gt;restart();
+ $this-&gt;get('http://www.my-site.com/restricted.php');
+ $this-&gt;assertWantedPattern('/Access denied/');</strong>
+ }
+}
+</pre>
+ La méthode <span class="new_code">WebTestCase::restart()</span> préserve les cookies
+ dont le timeout a expiré, mais conserve les cookies temporaires ou expirés.
+ Vous pouvez spécifier l'heure et la date de leur réactivation.
+ </p>
+ <p>
+ L'expiration des cookies peut être un problème.
+ Si vous avez un cookie qui doit expirer au bout d'une heure,
+ nous n'allons pas mettre le test en veille en attendant
+ que le cookie expire...
+ </p>
+ <p>
+ Afin de provoquer leur expiration,
+ vous pouvez dater manuellement les cookies,
+ avant le début de la session.
+<pre>
+class LogInTest extends WebTestCase {
+ ...
+ function testLoseAuthenticationAfterOneHour() {
+ $this-&gt;get('http://www.my-site.com/login.php');
+ $this-&gt;setField('u', 'Me');
+ $this-&gt;setField('p', 'Secret');
+ $this-&gt;clickSubmit('Log in');
+ $this-&gt;assertWantedPattern('/Welcome Me/');
+ <strong>
+ $this-&gt;ageCookies(3600);</strong>
+ $this-&gt;restart();
+ $this-&gt;get('http://www.my-site.com/restricted.php');
+ $this-&gt;assertWantedPattern('/Access denied/');
+ }
+}
+</pre>
+ Après le redémarrage, les cookies seront plus vieux
+ d'une heure et que tous ceux dont la date d'expiration
+ sera passée auront disparus.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API du développeur pour SimpleTest</a> donne tous les détails sur les classes et les assertions disponibles.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/browser_documentation.html b/vendors/simpletest/docs/fr/browser_documentation.html
new file mode 100644
index 000000000..62abbbbb9
--- /dev/null
+++ b/vendors/simpletest/docs/fr/browser_documentation.html
@@ -0,0 +1,446 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : le composant de navigation web scriptable</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur le navigateur scriptable</h1>
+ This page...
+ <ul>
+<li>
+ Utiliser le <a href="#scripting">navigateur web dans des scripts</a>
+ </li>
+<li>
+ <a href="#deboguer">Déboguer</a> les erreurs sur les pages
+ </li>
+<li>
+ <a href="#unit">Tests complexes avec des navigateurs web multiples</a>
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ Le composant de navigation web de SimpleTest peut être utilisé
+ non seulement à l'extérieur de la classe <span class="new_code">WebTestCase</span>,
+ mais aussi indépendamment du framework SimpleTest lui-même.
+ </p>
+
+ <p><a class="target" name="script"><h2>Le navigateur scriptable</h2></a></p>
+ <p>
+ Vous pouvez utiliser le navigateur web dans des scripts PHP
+ pour confirmer que des services marchent bien comme il faut
+ ou pour extraire des informations à partir de ceux-ci de façon régulière.
+ Par exemple, voici un petit script pour extraire
+ le nombre de bogues ouverts dans PHP 5 à partir
+ du <a href="http://www.php.net/">site web PHP</a>...
+<pre>
+&lt;?php
+ require_once('simpletest/browser.php');
+
+ $browser = &amp;new SimpleBrowser();
+ $browser-&gt;get('http://php.net/');
+ $browser-&gt;clickLink('reporting bugs');
+ $browser-&gt;clickLink('statistics');
+ $browser-&gt;clickLink('PHP 5 bugs only');
+ $page = $browser-&gt;getContent();
+ preg_match('/status=Open.*?by=Any.*?(\d+)&lt;\/a&gt;/', $page, $matches);
+ print $matches[1];
+?&gt;
+</pre>
+ Bien sûr Il y a des méthodes plus simple pour réaliser
+ cet exemple en PHP. Par exemple, vous pourriez juste
+ utiliser la commande PHP <span class="new_code">file()</span> sur ce qui est
+ ici une page fixe. Cependant, en utilisant des scripts
+ avec le navigateur web vous vous autorisez l'authentification,
+ la gestion des cookies, le chargement automatique des fenêtres,
+ les redirections, la transmission de formulaires et la capacité
+ d'examiner les entêtes. De telles méthodes sont fragiles dans
+ un site en constante évolution et vous voudrez employer une méthode
+ plus directe pour accéder aux données de façon permanente,
+ mais pour des tâches simples cette technique peut s'avérer
+ une solution très rapide.
+ </p>
+ <p>
+ Toutes les méthode de navigation utilisées dans <a href="web_tester_documentation.html">WebTestCase</a> sont présente dans la classe <span class="new_code">SimpleBrowser</span>, mais les assertions sont remplacées par de simples accesseurs. Voici une liste complète des méthodes de navigation de page à page...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">addHeader($header)</span></td>
+<td>Ajouter une entête à chaque téléchargement</td>
+</tr>
+ <tr>
+<td><span class="new_code">useProxy($proxy, $username, $password)</span></td>
+<td>Utilise ce proxy à partir de maintenant</td>
+</tr>
+ <tr>
+<td><span class="new_code">head($url, $parameters)</span></td>
+<td>Effectue une requête HEAD</td>
+</tr>
+ <tr>
+<td><span class="new_code">get($url, $parameters)</span></td>
+<td>Télécharge une page avec un GET</td>
+</tr>
+ <tr>
+<td><span class="new_code">post($url, $parameters)</span></td>
+<td>Télécharge une page avec un POST</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLink($label)</span></td>
+<td>Suit un lien par son étiquette</td>
+</tr>
+ <tr>
+<td><span class="new_code">isLink($label)</span></td>
+<td>Vérifie l'existance d'un lien par son étiquette</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLinkById($id)</span></td>
+<td>Suit un lien par son attribut d'identification</td>
+</tr>
+ <tr>
+<td><span class="new_code">isLinkById($id)</span></td>
+<td>Vérifie l'existance d'un lien par son attribut d'identification</td>
+</tr>
+ <tr>
+<td><span class="new_code">getUrl()</span></td>
+<td>La page ou la fenêtre URL en cours</td>
+</tr>
+ <tr>
+<td><span class="new_code">getTitle()</span></td>
+<td>Le titre de la page</td>
+</tr>
+ <tr>
+<td><span class="new_code">getContent()</span></td>
+<td>Le page ou la fenêtre brute</td>
+</tr>
+ <tr>
+<td><span class="new_code">getContentAsText()</span></td>
+<td>Sans code HTML à l'exception du text "alt"</td>
+</tr>
+ <tr>
+<td><span class="new_code">retry()</span></td>
+<td>Répète la dernière requête</td>
+</tr>
+ <tr>
+<td><span class="new_code">back()</span></td>
+<td>Utilise le bouton "précédent" du navigateur</td>
+</tr>
+ <tr>
+<td><span class="new_code">forward()</span></td>
+<td>Utilise le bouton "suivant" du navigateur</td>
+</tr>
+ <tr>
+<td><span class="new_code">authenticate($username, $password)</span></td>
+<td>Retente la page ou la fenêtre après une réponse 401</td>
+</tr>
+ <tr>
+<td><span class="new_code">restart($date)</span></td>
+<td>Relance le navigateur pour une nouvelle session</td>
+</tr>
+ <tr>
+<td><span class="new_code">ageCookies($interval)</span></td>
+<td>Change la date des cookies</td>
+</tr>
+ <tr>
+<td><span class="new_code">setCookie($name, $value)</span></td>
+<td>Lance un nouveau cookie</td>
+</tr>
+ <tr>
+<td><span class="new_code">getCookieValue($host, $path, $name)</span></td>
+<td>Lit le cookie le plus spécifique</td>
+</tr>
+ <tr>
+<td><span class="new_code">getCurrentCookieValue($name)</span></td>
+<td>Lit le contenue du cookie en cours</td>
+</tr>
+ </tbody></table>
+ Les méthode <span class="new_code">SimpleBrowser::useProxy()</span> et
+ <span class="new_code">SimpleBrowser::addHeader()</span> sont spéciales.
+ Une fois appelées, elles continuent à s'appliquer sur les téléchargements suivants.
+ </p>
+ <p>
+ Naviguer dans les formulaires est similaire à la <a href="form_testing_documentation.html">navigation des formulaires via WebTestCase</a>...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">setField($name, $value)</span></td>
+<td>Modifie tous les champs avec ce nom</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFieldById($id, $value)</span></td>
+<td>Modifie tous les champs avec cet identifiant</td>
+</tr>
+ <tr>
+<td><span class="new_code">getField($name)</span></td>
+<td>Accesseur de la valeur d'un élément de formulaire</td>
+</tr>
+ <tr>
+<td><span class="new_code">getFieldById($id)</span></td>
+<td>Accesseur de la valeur de l'élément de formulaire avec cet identifiant</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmit($label)</span></td>
+<td>Transmet le formulaire avec l'étiquette de son bouton</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitByName($name)</span></td>
+<td>Transmet le formulaire avec l'attribut de son bouton</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitById($id)</span></td>
+<td>Transmet le formulaire avec l'identifiant de son bouton</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImage($label, $x, $y)</span></td>
+<td>Clique sur une balise input de type image par son titre (title="*") our son texte alternatif (alt="*")</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageByName($name, $x, $y)</span></td>
+<td>Clique sur une balise input de type image par son attribut (name="*")</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageById($id, $x, $y)</span></td>
+<td>Clique sur une balise input de type image par son identifiant (id="*")</td>
+</tr>
+ <tr>
+<td><span class="new_code">submitFormById($id)</span></td>
+<td>Transmet le formulaire par son identifiant propre</td>
+</tr>
+ </tbody></table>
+ Au jourd d'aujourd'hui il n'existe aucune méthode pour lister
+ les formulaires et les champs disponibles : ce sera probablement
+ ajouté dans des versions successives de SimpleTest.
+ </p>
+ <p>
+ A l'intérieur d'une page, les fenêtres individuelles peuvent être
+ sélectionnées. Si aucune sélection n'est réalisée alors
+ toutes les fenêtres sont fusionnées ensemble dans
+ une unique et grande page.
+ Le contenu de la page en cours sera une concaténation des
+ toutes les fenêtres dans l'ordre spécifié par les balises "frameset".
+ <table><tbody>
+ <tr>
+<td><span class="new_code">getFrames()</span></td>
+<td>Un déchargement de la structure de la fenêtre courante</td>
+</tr>
+ <tr>
+<td><span class="new_code">getFrameFocus()</span></td>
+<td>L'index ou l'étiquette de la fenêtre en courante</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocusByIndex($choice)</span></td>
+<td>Sélectionne la fenêtre numérotée à partir de 1</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocus($name)</span></td>
+<td>Sélectionne une fenêtre par son étiquette</td>
+</tr>
+ <tr>
+<td><span class="new_code">clearFrameFocus()</span></td>
+<td>Traite toutes les fenêtres comme une seule page</td>
+</tr>
+ </tbody></table>
+ Lorsqu'on est focalisé sur une fenêtre unique,
+ le contenu viendra de celle-ci uniquement.
+ Cela comprend les liens à cliquer et les formulaires à transmettre.
+ </p>
+
+ <p><a class="target" name="deboguer"><h2>Où sont les erreurs ?</h2></a></p>
+ <p>
+ Toute cette masse de fonctionnalités est géniale
+ lorsqu'on arrive à bien télécharger les pages,
+ mais ce n'est pas toujours évident.
+ Pour aider à découvrir les erreurs, le navigateur a aussi
+ des méthodes pour aider au débogage.
+ <table><tbody>
+ <tr>
+<td><span class="new_code">setConnectionTimeout($timeout)</span></td>
+<td>Ferme la socket avec un délai trop long</td>
+</tr>
+ <tr>
+<td><span class="new_code">getRequest()</span></td>
+<td>L'entête de la requête brute de la page ou de la fenêtre</td>
+</tr>
+ <tr>
+<td><span class="new_code">getHeaders()</span></td>
+<td>L'entête de réponse de la page ou de la fenêtre</td>
+</tr>
+ <tr>
+<td><span class="new_code">getTransportError()</span></td>
+<td>N'importe quel erreur au niveau de la socket dans le dernier téléchargement</td>
+</tr>
+ <tr>
+<td><span class="new_code">getResponseCode()</span></td>
+<td>La réponse HTTP de la page ou de la fenêtre</td>
+</tr>
+ <tr>
+<td><span class="new_code">getMimeType()</span></td>
+<td>Le type Mime de la page our de la fenêtre</td>
+</tr>
+ <tr>
+<td><span class="new_code">getAuthentication()</span></td>
+<td>Le type d'authentification dans l'entête d'une provocation 401</td>
+</tr>
+ <tr>
+<td><span class="new_code">getRealm()</span></td>
+<td>Le realm d'authentification dans l'entête d'une provocation 401</td>
+</tr>
+ <tr>
+<td><span class="new_code">setMaximumRedirects($max)</span></td>
+<td>Nombre de redirections avant que la page ne soit chargée automatiquement</td>
+</tr>
+ <tr>
+<td><span class="new_code">setMaximumNestedFrames($max)</span></td>
+<td>Protection contre des framesets récursifs</td>
+</tr>
+ <tr>
+<td><span class="new_code">ignoreFrames()</span></td>
+<td>Neutralise le support des fenêtres</td>
+</tr>
+ <tr>
+<td><span class="new_code">useFrames()</span></td>
+<td>Autorise le support des fenêtres</td>
+</tr>
+ </tbody></table>
+ Les méthodes <span class="new_code">SimpleBrowser::setConnectionTimeout()</span>,
+ <span class="new_code">SimpleBrowser::setMaximumRedirects()</span>,
+ <span class="new_code">SimpleBrowser::setMaximumNestedFrames()</span>,
+ <span class="new_code">SimpleBrowser::ignoreFrames()</span>
+ et <span class="new_code">SimpleBrowser::useFrames()</span> continuent à s'appliquer
+ sur toutes les requêtes suivantes.
+ Les autres méthodes tiennent compte des fenêtres.
+ Cela veut dire que si une fenêtre individuelle ne se charge pas,
+ il suffit de se diriger vers elle avec
+ <span class="new_code">SimpleBrowser::setFrameFocus()</span> : ensuite on utilisera
+ <span class="new_code">SimpleBrowser::getRequest()</span>, etc. pour voir ce qui se passe.
+ </p>
+
+ <p><a class="target" name="unit"><h2>Tests unitaires complexes avec des navigateurs multiples</h2></a></p>
+ <p>
+ Tout ce qui peut être fait dans
+ <a href="web_tester_documentation.html">WebTestCase</a> peut maintenant
+ être fait dans un <a href="unit_tester_documentation.html">UnitTestCase</a>.
+ Ce qui revient à dire que nous pouvons librement mélanger
+ des tests sur des objets de domaine avec l'interface web...
+<pre><strong>
+class TestOfRegistration extends UnitTestCase {
+ function testNewUserAddedToAuthenticator() {</strong>
+ $browser = &amp;new SimpleBrowser();
+ $browser-&gt;get('http://my-site.com/register.php');
+ $browser-&gt;setField('email', 'me@here');
+ $browser-&gt;setField('password', 'Secret');
+ $browser-&gt;clickSubmit('Register');
+ <strong>
+ $authenticator = &amp;new Authenticator();
+ $member = &amp;$authenticator-&gt;findByEmail('me@here');
+ $this-&gt;assertEqual($member-&gt;getPassword(), 'Secret');</strong>
+ }
+}
+</pre>
+ Bien que ça puisse être utile par convenance temporaire,
+ je ne suis pas fan de ce genre de test. Ce test s'applique
+ à plusieurs couches de l'application, ça implique qu'il est
+ plus que probable qu'il faudra le remanier lorsque le code changera.
+ </p>
+ <p>
+ Un cas plus utile d'utilisation directe du navigateur est
+ le moment où le <span class="new_code">WebTestCase</span> ne peut plus suivre.
+ Un exemple ? Quand deux navigateurs doivent être utilisés en même temps.
+ </p>
+ <p>
+ Par exemple, supposons que nous voulions interdire
+ des usages simultanés d'un site avec le même login d'identification.
+ Ce scénario de test le vérifie...
+<pre>
+class TestOfSecurity extends UnitTestCase {
+ function testNoMultipleLoginsFromSameUser() {
+ $first = &amp;new SimpleBrowser();
+ $first-&gt;get('http://my-site.com/login.php');
+ $first-&gt;setField('name', 'Me');
+ $first-&gt;setField('password', 'Secret');
+ $first-&gt;clickSubmit('Enter');
+ $this-&gt;assertEqual($first-&gt;getTitle(), 'Welcome');
+
+ $second = &amp;new SimpleBrowser();
+ $second-&gt;get('http://my-site.com/login.php');
+ $second-&gt;setField('name', 'Me');
+ $second-&gt;setField('password', 'Secret');
+ $second-&gt;clickSubmit('Enter');
+ $this-&gt;assertEqual($second-&gt;getTitle(), 'Access Denied');
+ }
+}
+</pre>
+ Vous pouvez aussi utiliser la classe <span class="new_code">SimpleBrowser</span>
+ quand vous souhaitez écrire des scénarios de test en utilisant
+ un autre outil que SimpleTest.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API de développeur pour SimpleTest</a>
+ donne tous les détails sur les classes et les assertions disponibles.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/docs.css b/vendors/simpletest/docs/fr/docs.css
new file mode 100644
index 000000000..49170486a
--- /dev/null
+++ b/vendors/simpletest/docs/fr/docs.css
@@ -0,0 +1,84 @@
+body {
+ padding-left: 3%;
+ padding-right: 3%;
+}
+pre {
+ font-family: "courier new", courier;
+ font-size: 80%;
+ border: 1px solid;
+ background-color: #cccccc;
+ padding: 5px;
+ margin-left: 5%;
+ margin-right: 8%;
+}
+.code, .new_code, pre.new_code {
+ font-weight: bold;
+}
+div.copyright {
+ font-size: 80%;
+ color: gray;
+}
+div.copyright a {
+ color: gray;
+}
+ul.api {
+ padding-left: 0em;
+ padding-right: 25%;
+}
+ul.api li {
+ margin-top: 0.2em;
+ margin-bottom: 0.2em;
+ list-style: none;
+ text-indent: -3em;
+ padding-left: 3em;
+}
+div.demo {
+ border: 4px ridge;
+ border-color: gray;
+ padding: 10px;
+ margin: 5px;
+ margin-left: 20px;
+ margin-right: 40px;
+ background-color: white;
+}
+div.demo span.fail {
+ color: red;
+}
+div.demo span.pass {
+ color: green;
+}
+div.demo h1 {
+ font-size: 12pt;
+ text-align: left;
+ font-weight: bold;
+}
+table {
+ border: 2px outset;
+ border-color: gray;
+ background-color: white;
+ margin: 5px;
+ margin-left: 5%;
+ margin-right: 5%;
+}
+td {
+ font-size: 80%;
+}
+.shell {
+ color: white;
+}
+pre.shell {
+ border: 4px ridge;
+ border-color: gray;
+ padding: 10px;
+ margin: 5px;
+ margin-left: 20px;
+ margin-right: 40px;
+ background-color: black;
+}
+form.demo {
+ background-color: lightgray;
+ border: 4px outset;
+ border-color: lightgray;
+ padding: 10px;
+ margin-right: 40%;
+}
diff --git a/vendors/simpletest/docs/fr/expectation_documentation.html b/vendors/simpletest/docs/fr/expectation_documentation.html
new file mode 100644
index 000000000..c9408a7f3
--- /dev/null
+++ b/vendors/simpletest/docs/fr/expectation_documentation.html
@@ -0,0 +1,383 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : étendre le testeur unitaire avec des classes d'attentes supplémentaires</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur les attentes</h1>
+ This page...
+ <ul>
+<li>
+ Utiliser les attentes <a href="#fantaisie">pour des tests
+ plus précis avec des objets fantaisie</a>
+ </li>
+<li>
+ <a href="#comportement">Changer le comportement d'un objet fantaisie</a>
+ avec des attentes
+ </li>
+<li>
+ <a href="#etendre">Créer des attentes</a>
+ </li>
+<li>
+ Par dessous SimpleTest <a href="#unitaire">utilise des classes d'attente</a>
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="fantaisie"><h2>Plus de contrôle sur les objets fantaisie</h2></a></p>
+ <p>
+ Le comportement par défaut des
+ <a href="mock_objects_documentation.html">objets fantaisie</a> dans
+ <a href="http://sourceforge.net/projects/simpletest/">SimpleTest</a>
+ est soit une correspondance identique sur l'argument,
+ soit l'acceptation de n'importe quel argument.
+ Pour la plupart des tests, c'est suffisant.
+ Cependant il est parfois nécessaire de ramollir un scénario de test.
+ </p>
+ <p>
+ Un des endroits où un test peut être trop serré
+ est la reconnaissance textuelle. Prenons l'exemple
+ d'un composant qui produirait un message d'erreur
+ utile lorsque quelque chose plante. Il serait utile de tester
+ que l'erreur correcte est renvoyée,
+ mais le texte proprement dit risque d'être plutôt long.
+ Si vous testez le texte dans son ensemble alors
+ à chaque modification de ce même message
+ -- même un point ou une virgule -- vous aurez
+ à revenir sur la suite de test pour la modifier.
+ </p>
+ <p>
+ Voici un cas concret, nous avons un service d'actualités
+ qui a échoué dans sa tentative de connexion à sa source distante.
+<pre>
+<strong>class NewsService {
+ ...
+ function publish(&amp;$writer) {
+ if (! $this-&gt;isConnected()) {
+ $writer-&gt;write('Cannot connect to news service "' .
+ $this-&gt;_name . '" at this time. ' .
+ 'Please try again later.');
+ }
+ ...
+ }
+}</strong>
+</pre>
+ Là il envoie son contenu vers un classe <span class="new_code">Writer</span>.
+ Nous pourrions tester ce comportement avec un <span class="new_code">MockWriter</span>...
+<pre>
+class TestOfNewsService extends UnitTestCase {
+ ...
+ function testConnectionFailure() {<strong>
+ $writer = &amp;new MockWriter($this);
+ $writer-&gt;expectOnce('write', array(
+ 'Cannot connect to news service ' .
+ '"BBC News" at this time. ' .
+ 'Please try again later.'));
+
+ $service = &amp;new NewsService('BBC News');
+ $service-&gt;publish($writer);
+
+ $writer-&gt;tally();</strong>
+ }
+}
+</pre>
+ C'est un bon exemple d'un test fragile.
+ Si nous décidons d'ajouter des instructions complémentaires,
+ par exemple proposer une source d'actualités alternative,
+ nous casserons nos tests par la même occasion sans pourtant
+ avoir modifié une seule fonctionnalité.
+ </p>
+ <p>
+ Pour contourner ce problème, nous voudrions utiliser
+ un test avec une expression rationnelle plutôt
+ qu'une correspondance exacte. Nous pouvons y parvenir avec...
+<pre>
+class TestOfNewsService extends UnitTestCase {
+ ...
+ function testConnectionFailure() {
+ $writer = &amp;new MockWriter($this);<strong>
+ $writer-&gt;expectOnce(
+ 'write',
+ array(new WantedPatternExpectation('/cannot connect/i')));</strong>
+
+ $service = &amp;new NewsService('BBC News');
+ $service-&gt;publish($writer);
+
+ $writer-&gt;tally();
+ }
+}
+</pre>
+ Plutôt que de transmettre le paramètre attendu au <span class="new_code">MockWriter</span>,
+ nous envoyons une classe d'attente appelée <span class="new_code">WantedPatternExpectation</span>.
+ L'objet fantaisie est suffisamment élégant pour reconnaître
+ qu'il s'agit d'un truc spécial et pour le traiter différemment.
+ Plutôt que de comparer l'argument entrant à cet objet,
+ il utilise l'objet attente lui-même pour exécuter le test.
+ </p>
+ <p>
+ <span class="new_code">WantedPatternExpectation</span> utilise
+ l'expression rationnelle pour la comparaison avec son constructeur.
+ A chaque fois qu'une comparaison est fait à travers
+ <span class="new_code">MockWriter</span> par rapport à cette classe attente,
+ elle fera un <span class="new_code">preg_match()</span> avec ce motif.
+ Dans notre scénario de test ci-dessus, aussi longtemps
+ que la chaîne "cannot connect" apparaît dans le texte,
+ la fantaisie transmettra un succès au testeur unitaire.
+ Peu importe le reste du texte.
+ </p>
+ <p>
+ Les classes attente possibles sont...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">EqualExpectation</span></td>
+<td>Une égalité, plutôt que la plus forte comparaison à l'identique</td>
+</tr>
+ <tr>
+<td><span class="new_code">NotEqualExpectation</span></td>
+<td>Une comparaison sur la non-égalité</td>
+</tr>
+ <tr>
+<td><span class="new_code">IndenticalExpectation</span></td>
+<td>La vérification par défaut de l'objet fantaisie qui doit correspondre exactement</td>
+</tr>
+ <tr>
+<td><span class="new_code">NotIndenticalExpectation</span></td>
+<td>Inverse la logique de l'objet fantaisie</td>
+</tr>
+ <tr>
+<td><span class="new_code">WantedPatternExpectation</span></td>
+<td>Utilise une expression rationnelle Perl pour comparer une chaîne</td>
+</tr>
+ <tr>
+<td><span class="new_code">NoUnwantedPatternExpectation</span></td>
+<td>Passe seulement si l'expression rationnelle Perl échoue</td>
+</tr>
+ <tr>
+<td><span class="new_code">IsAExpectation</span></td>
+<td>Vérifie le type ou le nom de la classe uniquement</td>
+</tr>
+ <tr>
+<td><span class="new_code">NotAExpectation</span></td>
+<td>L'opposé de <span class="new_code">IsAExpectation</span>
+</td>
+</tr>
+ <tr>
+<td><span class="new_code">MethodExistsExpectation</span></td>
+<td>Vérifie si la méthode est disponible sur un objet</td>
+</tr>
+ </tbody></table>
+ La plupart utilisent la valeur attendue dans le constructeur.
+ Les exceptions sont les vérifications sur motif,
+ qui utilisent une expression rationnelle, ainsi que
+ <span class="new_code">IsAExpectation</span> et <span class="new_code">NotAExpectation</span>,
+ qui prennent un type ou un nom de classe comme chaîne.
+ </p>
+
+ <p><a class="target" name="comportement"><h2>Utiliser les attentes pour contrôler les bouchons serveur</h2></a></p>
+ <p>
+ Les classes attente peuvent servir à autre chose
+ que l'envoi d'assertions depuis les objets fantaisie,
+ afin de choisir le comportement d'un
+ <a href="mock_objects_documentation.html">objet fantaisie</a>
+ ou celui d'un <a href="server_stubs_documentation.html">bouchon serveur</a>.
+ A chaque fois qu'une liste d'arguments est donnée,
+ une liste d'objets d'attente peut être insérée à la place.
+ </p>
+ <p>
+ Mettons que nous voulons qu'un bouchon serveur
+ d'autorisation simule une connexion réussie seulement
+ si il reçoit un objet de session valide.
+ Nous pouvons y arriver avec ce qui suit...
+<pre>
+Stub::generate('Authorisation');
+<strong>
+$authorisation = new StubAuthorisation();
+$authorisation-&gt;setReturnValue(
+ 'isAllowed',
+ true,
+ array(new IsAExpectation('Session', 'Must be a session')));
+$authorisation-&gt;setReturnValue('isAllowed', false);</strong>
+</pre>
+ Le comportement par défaut du bouchon serveur
+ est défini pour renvoyer <span class="new_code">false</span>
+ quand <span class="new_code">isAllowed</span> est appelé.
+ Lorsque nous appelons cette méthode avec un unique paramètre
+ qui est un objet <span class="new_code">Session</span>, il renverra <span class="new_code">true</span>.
+ Nous avons aussi ajouté un deuxième paramètre comme message.
+ Il sera affiché dans le message d'erreur de l'objet fantaisie
+ si l'attente est la cause de l'échec.
+ </p>
+ <p>
+ Ce niveau de sophistication est rarement utile :
+ il n'est inclut que pour être complet.
+ </p>
+
+ <p><a class="target" name="etendre"><h2>Créer vos propres attentes</h2></a></p>
+ <p>
+ Les classes d'attentes ont une structure très simple.
+ Tellement simple qu'il devient très simple de créer
+ vos propres version de logique pour des tests utilisés couramment.
+ </p>
+ <p>
+ Par exemple voici la création d'une classe pour tester
+ la validité d'adresses IP. Pour fonctionner correctement
+ avec les bouchons serveurs et les objets fantaisie,
+ cette nouvelle classe d'attente devrait étendre
+ <span class="new_code">SimpleExpectation</span>...
+<pre>
+<strong>class ValidIp extends SimpleExpectation {
+
+ function test($ip) {
+ return (ip2long($ip) != -1);
+ }
+
+ function testMessage($ip) {
+ return "Address [$ip] should be a valid IP address";
+ }
+}</strong>
+</pre>
+ Il n'y a véritablement que deux méthodes à mettre en place.
+ La méthode <span class="new_code">test()</span> devrait renvoyer un <span class="new_code">true</span>
+ si l'attente doit passer, et une erreur <span class="new_code">false</span>
+ dans le cas contraire. La méthode <span class="new_code">testMessage()</span>
+ ne devrait renvoyer que du texte utile à la compréhension du test en lui-même.
+ </p>
+ <p>
+ Cette classe peut désormais être employée à la place
+ des classes d'attente précédentes.
+ </p>
+
+ <p><a class="target" name="unitaire"><h2>Sous le capot du testeur unitaire</h2></a></p>
+ <p>
+ Le <a href="http://sourceforge.net/projects/simpletest/">framework
+ de test unitaire SimpleTest</a> utilise aussi dans son coeur
+ des classes d'attente pour
+ la <a href="unit_test_documentation.html">classe UnitTestCase</a>.
+ Nous pouvons aussi tirer parti de ces mécanismes pour réutiliser
+ nos propres classes attente à l'intérieur même des suites de test.
+ </p>
+ <p>
+ La méthode la plus directe est d'utiliser la méthode
+ <span class="new_code">SimpleTest::assertExpectation()</span> pour effectuer le test...
+<pre>
+<strong>class TestOfNetworking extends UnitTestCase {
+ ...
+ function testGetValidIp() {
+ $server = &amp;new Server();
+ $this-&gt;assertExpectation(
+ new ValidIp(),
+ $server-&gt;getIp(),
+ 'Server IP address-&gt;%s');
+ }
+}</strong>
+</pre>
+ C'est plutôt sale par rapport à notre syntaxe habituelle
+ du type <span class="new_code">assert...()</span>.
+ </p>
+ <p>
+ Pour un cas aussi simple, nous créons d'ordinaire une méthode
+ d'assertion distincte en utilisant la classe d'attente.
+ Supposons un instant que notre attente soit un peu plus
+ compliquée et que par conséquent nous souhaitions la réutiliser,
+ nous obtenons...
+<pre>
+class TestOfNetworking extends UnitTestCase {
+ ...<strong>
+ function assertValidIp($ip, $message = '%s') {
+ $this-&gt;assertExpectation(new ValidIp(), $ip, $message);
+ }</strong>
+
+ function testGetValidIp() {
+ $server = &amp;new Server();<strong>
+ $this-&gt;assertValidIp(
+ $server-&gt;getIp(),
+ 'Server IP address-&gt;%s');</strong>
+ }
+}
+</pre>
+ Il est peu probable que nous ayons besoin
+ de ce niveau de contrôle sur la machinerie de test.
+ Il est assez rare que le besoin d'une attente dépasse
+ le stade de la reconnaissance d'un motif.
+ De plus, les classes d'attente complexes peuvent rendre
+ les tests difficiles à lire et à déboguer.
+ Ces mécanismes sont véritablement là pour les auteurs
+ de système qui étendront le framework de test
+ pour leurs propres outils de test.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ Les attentes imitent les contraintes dans
+ <a href="http://www.jmock.org/">JMock</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API complète pour SimpleTest</a>
+ réalisé avec PHPDoc.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/form_testing_documentation.html b/vendors/simpletest/docs/fr/form_testing_documentation.html
new file mode 100644
index 000000000..4c30ef0cf
--- /dev/null
+++ b/vendors/simpletest/docs/fr/form_testing_documentation.html
@@ -0,0 +1,349 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : tester des formulaires HTML</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur les tests de formulaire</h1>
+ This page...
+ <ul>
+<li>
+ Modifier les valeurs d'un formulaire et
+ <a href="#submit">réussir à transmettre un simple formulaire</a>
+ </li>
+<li>
+ Gérer des <a href="#multiple">objets à valeurs multiples</a>
+ en initialisant des listes.
+ </li>
+<li>
+ Le cas des formulaires utilisant Javascript pour
+ modifier <a href="#hidden-field">un champ caché</a>
+ </li>
+<li>
+ <a href="#brut">Envoi brut</a> quand il n'existe pas de bouton à cliquer.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="submit"><h2>Valider un formulaire simple</h2></a></p>
+ <p>
+ Lorsqu'une page est téléchargée par <span class="new_code">WebTestCase</span>
+ en utilisant <span class="new_code">get()</span> ou <span class="new_code">post()</span>
+ le contenu de la page est automatiquement analysé.
+ De cette analyse découle le fait que toutes les commandes
+ à l'intérieur de la balise &lt;form&gt; sont disponibles
+ depuis l'intérieur du scénario de test.
+ Prenons par exemple cet extrait de code HTML...
+<pre>
+&lt;form&gt;
+ &lt;input type="text" name="a" value="A default" /&gt;
+ &lt;input type="submit" value="Go" /&gt;
+&lt;/form&gt;
+</pre>
+ Il ressemble à...
+ </p>
+ <p>
+ <form class="demo">
+ <input type="text" name="a" value="A default">
+ <input type="submit" value="Go">
+ </form>
+ </p>
+ <p>
+ Nous pouvons naviguer vers ce code, via le site
+ <a href="http://www.lastcraft.com/form_testing_documentation.php">LastCraft</a>,
+ avec le test suivant...
+<pre>
+class SimpleFormTests extends WebTestCase {
+ <strong>
+ function testDefaultValue() {
+ $this-&gt;get('http://www.lastcraft.com/form_testing_documentation.php');
+ $this-&gt;assertField('a', 'A default');
+ }</strong>
+}
+</pre>
+ Directement après le chargement de la page toutes les commandes HTML
+ sont initiées avec leur valeur par défaut, comme elles apparaîtraient
+ dans un navigateur web. L'assertion teste qu'un objet HTML
+ avec le nom "a" existe dans la page
+ et qu'il contient la valeur "A default".
+ </p>
+ <p>
+ Nous pourrions retourner le formulaire tout de suite,
+ mais d'abord nous allons changer la valeur du champ texte.
+ Ce n'est qu'après que nous le transmettrons...
+<pre>
+class SimpleFormTests extends WebTestCase {
+
+ function testDefaultValue() {
+ $this-&gt;get('http://www.my-site.com/');
+ $this-&gt;assertField('a', 'A default');<strong>
+ $this-&gt;setField('a', 'New value');
+ $this-&gt;clickSubmit('Go');</strong>
+ }
+}
+</pre>
+ Parce que nous n'avons spécifié ni attribut "method"
+ sur la balise form, ni attribut "action",
+ le scénario de test suivra le comportement classique d'un navigateur :
+ transmission des données avec une requête <em>GET</em>
+ vers la même page. SimpleTest essaie d'émuler
+ le comportement typique d'un navigateur autant que possible,
+ plutôt que d'essayer d'attraper des attributs manquants sur les balises.
+ La raison est simple : la cible d'un framework de test est
+ la logique d'une application PHP, pas les erreurs
+ -- de syntaxe ou autres -- du code HTML.
+ Pour les erreurs HTML, d'autres outils tel
+ <a href="http://www.w3.org/People/Raggett/tidy/">HTMLTidy</a>
+ devraient être employés.
+ </p>
+ <p>
+ Si un champ manque dans n'importe quel formulaire ou si
+ une option est indisponible alors <span class="new_code">WebTestCase::setField()</span>
+ renverra <span class="new_code">false</span>. Par exemple, supposons que
+ nous souhaitons vérifier qu'une option "Superuser"
+ n'est pas présente dans ce formulaire...
+<pre>
+&lt;strong&gt;Select type of user to add:&lt;/strong&gt;
+&lt;select name="type"&gt;
+ &lt;option&gt;Subscriber&lt;/option&gt;
+ &lt;option&gt;Author&lt;/option&gt;
+ &lt;option&gt;Administrator&lt;/option&gt;
+&lt;/select&gt;
+</pre>
+ Qui ressemble à...
+ </p>
+ <p>
+ <form class="demo">
+ <strong>Select type of user to add:</strong>
+ <select name="type">
+ <option>Subscriber</option>
+ <option>Author</option>
+ <option>Administrator</option>
+ </select>
+ </form>
+ </p>
+ <p>
+ Le test suivant le confirmera...
+<pre>
+class SimpleFormTests extends WebTestCase {
+ ...
+ function testNoSuperuserChoiceAvailable() {<strong>
+ $this-&gt;get('http://www.lastcraft.com/form_testing_documentation.php');
+ $this-&gt;assertFalse($this-&gt;setField('type', 'Superuser'));</strong>
+ }
+}
+</pre>
+ La sélection ne sera pas changée suite à un échec d'initialisation
+ d'une valeur sur un objet.
+ </p>
+ <p>
+ Voici la liste complète des objets supportés à aujourd'hui...
+ <ul>
+ <li>Champs texte, y compris les champs masqués (hidden) ou cryptés (password).</li>
+ <li>Boutons submit, en incluant aussi la balise button, mais pas encore les boutons reset</li>
+ <li>Aires texte (textarea) avec leur gestion des retours à la ligne (wrap).</li>
+ <li>Cases à cocher, y compris les cases à cocher multiples dans un même formulaire.</li>
+ <li>Listes à menu déroulant, y compris celles à sélections multiples.</li>
+ <li>Boutons radio.</li>
+ <li>Images.</li>
+ </ul>
+ </p>
+ <p>
+ Le navigateur proposé par SimpleTest émule les actions
+ qui peuvent être réalisées par un utilisateur sur
+ une page HTML standard. Javascript n'est pas supporté et
+ il y a peu de chance pour qu'il le soit prochainement.
+ </p>
+ <p>
+ Une attention particulière doit être porté aux techniques Javascript
+ qui changent la valeur d'un champ caché : elles ne peuvent pas être
+ réalisées avec les commandes classiques de SimpleTest.
+ Une méthode alternative est proposée plus loin.
+ </p>
+
+ <p><a class="target" name="multiple"><h2>Champs à valeurs multiples</h2></a></p>
+ <p>
+ SimpleTest peut gérer deux types de commandes à valeur multiple :
+ les menus déroulants à sélection multiple et les cases à cocher
+ avec le même nom à l'intérieur même d'un formulaire.
+ La nature de ceux-ci implique que leur initialisation
+ et leur test sont légèrement différents.
+ Voici un exemple avec des cases à cocher...
+<pre>
+&lt;form class="demo"&gt;
+ &lt;strong&gt;Create privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="c" checked&gt;&lt;br&gt;
+ &lt;strong&gt;Retrieve privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="r" checked&gt;&lt;br&gt;
+ &lt;strong&gt;Update privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="u" checked&gt;&lt;br&gt;
+ &lt;strong&gt;Destroy privileges allowed:&lt;/strong&gt;
+ &lt;input type="checkbox" name="crud" value="d" checked&gt;&lt;br&gt;
+ &lt;input type="submit" value="Enable Privileges"&gt;
+&lt;/form&gt;
+</pre>
+ Qui se traduit par...
+ </p>
+ <p>
+ <form class="demo">
+ <strong>Create privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="c" checked><br>
+ <strong>Retrieve privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="r" checked><br>
+ <strong>Update privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="u" checked><br>
+ <strong>Destroy privileges allowed:</strong>
+ <input type="checkbox" name="crud" value="d" checked><br>
+ <input type="submit" value="Enable Privileges">
+ </form>
+ </p>
+ <p>
+ Si nous souhaitons désactiver tous les privilèges sauf
+ ceux de téléchargement (Retrieve) et transmettre cette information,
+ nous pouvons y arriver par...
+<pre>
+class SimpleFormTests extends WebTestCase {
+ ...<strong>
+ function testDisableNastyPrivileges() {
+ $this-&gt;get('http://www.lastcraft.com/form_testing_documentation.php');
+ $this-&gt;assertField('crud', array('c', 'r', 'u', 'd'));
+ $this-&gt;setField('crud', array('r'));
+ $this-&gt;clickSubmit('Enable Privileges');
+ }</strong>
+}
+</pre>
+ Plutôt que d'initier le champ à une valeur unique,
+ nous lui donnons une liste de valeurs.
+ Nous faisons la même chose pour tester les valeurs attendues.
+ Nous pouvons écrire d'autres bouts de code de test
+ pour confirmer cet effet, peut-être en nous connectant
+ comme utilisateur et en essayant d'effectuer une mise à jour.
+ </p>
+
+ <p><a class="target" name="hidden-field"><h2>Formulaires utilisant Javascript pour changer un champ caché</h2></a></p>
+ <p>
+ Si vous souhaitez tester un formulaire dépendant de Javascript
+ pour la modification d'un champ caché, vous ne pouvez pas
+ simplement utiliser setField().
+ Le code suivant <em>ne fonctionnera pas</em> :
+<pre>
+class SimpleFormTests extends WebTestCase {
+ function testMyJavascriptForm() {
+ <strong>// Ne fonctionne *pas*</strong>
+ $this-&gt;setField('un_champ_caché', '123');
+ $this-&gt;clickSubmit('OK');
+ }
+}
+</pre>
+ A la place, vous aurez besoin d'ajouter le paramètre supplémentaire
+ du formulaire à la méthode clickSubmit() :
+<pre>
+class SimpleFormTests extends WebTestCase {
+ function testMyJavascriptForm() {
+ // Ajoute le champ caché comme variable POST supplémentaire
+ <strong>$this-&gt;clickSubmit('OK', array('un_champ_caché'=&gt;'123'));</strong>
+ }
+
+}
+</pre>
+ </p>
+ <p>
+ N'oubliez pas que de la sorte, vous êtes effectivement en train
+ de court-circuitez une partie de votre application (le code Javascript
+ dans le formulaire) et que peut-être serait-il plus prudent
+ d'utiliser un outil comme
+ <a href="http://selenium.openqa.org/">Selenium</a> pour mettre sur pied
+ un test de recette complet.
+ </p>
+
+ <p><a class="target" name="brut"><h2>Envoi brut</h2></a></p>
+ <p>
+ Si vous souhaitez tester un gestionnaire de formulaire
+ mais que vous ne l'avez pas écrit ou que vous n'y avez
+ pas encore accès, vous pouvez créer un envoi de formulaire à la main.
+<pre>
+class SimpleFormTests extends WebTestCase {
+ ...<strong>
+ function testAttemptedHack() {
+ $this-&gt;post(
+ 'http://www.my-site.com/add_user.php',
+ array('type' =&gt; 'superuser'));
+ $this-&gt;assertNoUnwantedPattern('/user created/i');
+ }</strong>
+}
+</pre>
+ En ajoutant des données à la méthode <span class="new_code">WebTestCase::post()</span>,
+ nous essayons de télécharger la page via la transmission d'un formulaire.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API du développeur pour SimpleTest</a>
+ donne tous les détails sur les classes et les assertions disponibles.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/group_test_documentation.html b/vendors/simpletest/docs/fr/group_test_documentation.html
new file mode 100644
index 000000000..b993475ab
--- /dev/null
+++ b/vendors/simpletest/docs/fr/group_test_documentation.html
@@ -0,0 +1,398 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : Grouper des tests</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur le groupement des tests</h1>
+ This page...
+ <ul>
+<li>
+ Plusieurs approches pour <a href="#group">grouper des tests</a> ensemble.
+ </li>
+<li>
+ Combiner des groupes des tests dans des
+ <a href="#plus-haut">groupes plus grands</a>.
+ </li>
+<li>
+ Intégrer des <a href="#heritage">scénarios de test hérités</a>
+ d'un autre type de PHPUnit.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="grouper"><h2>Grouper des tests</h2></a></p>
+ <p>
+ Pour lancer les scénarios de tests en tant que groupe,
+ ils devraient être placés dans des fichiers sans le code du lanceur...
+<pre>
+<strong>&lt;?php
+ require_once('../classes/io.php');
+
+ class FileTester extends UnitTestCase {
+ ...
+ }
+
+ class SocketTester extends UnitTestCase {
+ ...
+ }
+?&gt;</strong>
+</pre>
+ Autant de scénarios que nécessaires peuvent être
+ mis dans un fichier unique. Ils doivent contenir
+ tout le code nécessaire, entre autres la bibliothèque testée,
+ mais aucune des bibliothèques de SimpleTest.
+ </p>
+ <p>
+ Si vous avez étendu l'un ou l'autre des scénarios de test,
+ vous pouvez aussi les inclure.
+<pre>
+&lt;?php
+ require_once('../classes/io.php');
+<strong>
+ class MyFileTestCase extends UnitTestCase {
+ ...
+ }
+ SimpleTestOptions::ignore('MyFileTestCase');</strong>
+
+ class FileTester extends MyFileTestCase {
+ ...
+ }
+
+ class SocketTester extends UnitTestCase {
+ ...
+ }
+?&gt;
+</pre>
+ La classe <span class="new_code">FileTester</span> ne contient aucun test véritable,
+ il s'agit d'une classe de base pour d'autres scénarios de test.
+ Pour cette raison nous utilisons la directive
+ <span class="new_code">SimpleTestOptions::ignore()</span> pour indiquer
+ au prochain groupe de tests de l'ignorer.
+ Cette directive peut se placer n'importe où dans le fichier
+ et fonctionne quand un fichier complet des scénarios de test
+ est chargé (cf. ci-dessous).
+ Nous l'appelons <em>file_test.php</em>.
+ </p>
+ <p>
+ Ensuite nous créons un fichier de groupe de tests,
+ disons <em>group_test.php</em>.
+ Vous penserez à un nom plus convaincant, j'en suis sûr.
+ Nous lui ajoutons le fichier de test avec une méthode sans risque...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');<strong>
+ require_once('file_test.php');
+
+ $test = &amp;new GroupTest('All file tests');
+ $test-&gt;addTestCase(new FileTestCase());
+ $test-&gt;run(new HtmlReporter());</strong>
+?&gt;
+</pre>
+ Ceci instancie le scénario de test avant que
+ la suite de test ne soit lancée.
+ Ça pourrait devenir assez onéreux avec
+ un grand nombre de scénarios de test :
+ il existe donc une autre méthode qui instancie
+ la classe uniquement quand elle devient nécessaire...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');
+ require_once('file_test.php');
+
+ $test = &amp;new GroupTest('All file tests');<strong>
+ $test-&gt;addTestClass('FileTestCase');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ Le problème de cette technique est que pour
+ chaque scénario de test supplémentaire nous aurons à importer
+ (via <span class="new_code">require_once()</span>) le fichier de code de test
+ et à instancier manuellement chaque scénario de test.
+ Nous pouvons nous épargner beaucoup de dactylographie avec...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');
+
+ $test = &amp;new GroupTest('All file tests');<strong>
+ $test-&gt;addTestFile('file_test.php');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ Voici ce qui vient de se passer :
+ la classe <span class="new_code">GroupTest</span> a réalisé le
+ <span class="new_code">require_once()</span> pour nous.
+ Ensuite elle vérifie si de nouvelles classes de scénario
+ de test ont été créées par ce nouveau fichier
+ et les ajoute automatiquement au groupe de tests.
+ Désormais tout ce qu'il nous reste à faire,
+ c'est d'ajouter chaque nouveau fichier.
+ </p>
+ <p>
+ Il y a deux choses qui peuvent planter
+ et qui demandent un minimum d'attention...
+ <ol>
+ <li>
+ Le fichier peut déjà avoir été analysé par PHP
+ et dans ce cas aucune classe ne sera ajoutée.
+ Pensez à bien vérifier que les scénarios de test
+ ne sont inclus que dans ce fichier et dans aucun autre
+ (Note : avec la nouvelle fonctionnalité <cite>autorun</cite>,
+ ce problème a maintenant été résolu).
+ </li>
+ <li>
+ Les nouvelles classes d'extension de scénario
+ de test qui sont incluses seront placées
+ dans le groupe de tests et exécutées par la même occasion.
+ Vous aurez à ajouter une directive
+ <span class="new_code">SimpleTestOptions::ignore()</span> pour ces classes
+ ou alors pensez à les ajouter avant la ligne
+ <span class="new_code">GroupTest::addTestFile()</span>.
+ </li>
+ </ol>
+ </p>
+
+ <p><a class="target" name="plus-haut"><h2>Groupements de plus haut niveau</h2></a></p>
+ <p>
+ La technique ci-dessus place tous les scénarios de test
+ dans un unique et grand groupe.
+ Sauf que pour des projets plus conséquents,
+ ce n'est probablement pas assez souple;
+ vous voudriez peut-être grouper les tests tout à fait différemment.
+ </p>
+ <p>
+ Pour obtenir un groupe de tests plus souple
+ nous pouvons sous classer <span class="new_code">GroupTest</span>
+ et ensuite l'instancier au cas par cas...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');
+ <strong>
+ class FileGroupTest extends GroupTest {
+ function FileGroupTest() {
+ $this-&gt;GroupTest('All file tests');
+ $this-&gt;addTestFile('file_test.php');
+ }
+ }</strong>
+?&gt;
+</pre>
+ Ceci nomme le test dans le constructeur
+ et ensuite ajoute à la fois nos scénarios
+ de test et un unique groupe en dessous.
+ Bien sûr nous pouvons ajouter plus d'un groupe à cet instant.
+ Nous pouvons maintenant invoquer les tests
+ à partir d'un autre fichier d'exécution...
+<pre>
+&lt;?php
+ require_once('file_group_test.php');
+ <strong>
+ $test = &amp;new FileGroupTest();
+ $test-&gt;run(new HtmlReporter());</strong>
+?&gt;
+</pre>
+ ...ou alors nous pouvons les grouper
+ dans un groupe de tests encore plus grand...
+<pre>
+&lt;?php
+ require_once('file_group_test.php');
+ <strong>
+ $test = &amp;new BigGroupTest('Big group');
+ $test-&gt;addTestCase(new FileGroupTest());
+ $test-&gt;addTestCase(...);
+ $test-&gt;run(new HtmlReporter());</strong>
+?&gt;
+</pre>
+ Si nous souhaitons lancer le groupe de tests original
+ sans utiliser ses petits fichiers d'exécution,
+ nous pouvons mettre le code du lanceur de test
+ derrière des barreaux quand nous créons chaque groupe.
+<pre>
+&lt;?php
+ class FileGroupTest extends GroupTest {
+ function FileGroupTest() {
+ $this-&gt;GroupTest('All file tests');
+ $test-&gt;addTestFile('file_test.php');
+ }
+ }
+ <strong>
+ if (! defined('RUNNER')) {
+ define('RUNNER', true);</strong>
+ $test = &amp;new FileGroupTest();
+ $test-&gt;run(new HtmlReporter());
+ }
+?&gt;
+</pre>
+ Cette approche exige aux barrières d'être activées
+ à l'inclusion du fichier de groupe de tests,
+ mais c'est quand même moins de tracas que beaucoup
+ de fichiers de lancement éparpillés.
+ Reste à inclure des barreaux identiques
+ au niveau supérieur afin de s'assurer que
+ le <span class="new_code">run()</span> ne sera lancé qu'une seule fois
+ à partir du script de haut niveau qui l'a invoqué.
+<pre>
+&lt;?php
+ define('RUNNER', true);
+
+ require_once('file_group_test.php');
+ $test = &amp;new BigGroupTest('Big group');
+ $test-&gt;addTestCase(new FileGroupTest());
+ $test-&gt;addTestCase(...);
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ Comme les scénarios de test normaux,
+ un <span class="new_code">GroupTest</span> peut être chargé avec la méthode
+ <span class="new_code">GroupTest::addTestFile()</span>.
+<pre>
+&lt;?php
+ define('RUNNER', true);
+
+ $test = &amp;new BigGroupTest('Big group');<strong>
+ $test-&gt;addTestFile('file_group_test.php');
+ $test-&gt;addTestFile(...);</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ </p>
+
+ <p><a class="target" name="heritage"><h2>Intégrer des scénarios de test hérités</h2></a></p>
+ <p>
+ Si vous avez déjà des tests unitaires pour votre code
+ ou alors si vous étendez des classes externes
+ qui ont déjà leurs propres tests, il y a peu de chances
+ pour que ceux-ci soient déjà au format SimpleTest.
+ Heureusement il est possible d'incorporer ces scénarios
+ de test en provenance d'autres testeurs unitaires
+ directement dans des groupes de test SimpleTest.
+ </p>
+ <p>
+ Par exemple, supposons que nous ayons
+ ce scénario de test prévu pour
+ <a href="http://sourceforge.net/projects/phpunit">PhpUnit</a>
+ dans le fichier <em>config_test.php</em>...
+<pre>
+<strong>class ConfigFileTest extends TestCase {
+ function ConfigFileTest() {
+ $this-&gt;TestCase('Config file test');
+ }
+
+ function testContents() {
+ $config = new ConfigFile('test.conf');
+ $this-&gt;assertRegexp('/me/', $config-&gt;getValue('username'));
+ }
+}</strong>
+</pre>
+ Le groupe de tests peut le reconnaître à partir
+ du moment où nous mettons l'adaptateur approprié
+ avant d'ajouter le fichier de test...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');<strong>
+ require_once('simpletest/adapters/phpunit_test_case.php');</strong>
+
+ $test = &amp;new GroupTest('All file tests');<strong>
+ $test-&gt;addTestFile('config_test.php');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ Il n'y a que deux adaptateurs,
+ l'autre est pour le paquet testeur unitaire de
+ <a href="http://pear.php.net/manual/en/package.php.phpunit.php">PEAR</a>...
+<pre>
+&lt;?php
+ require_once('simpletest/unit_tester.php');
+ require_once('simpletest/reporter.php');<strong>
+ require_once('simpletest/adapters/pear_test_case.php');</strong>
+
+ $test = &amp;new GroupTest('All file tests');<strong>
+ $test-&gt;addTestFile('some_pear_test_cases.php');</strong>
+ $test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ Les scénarios de test de PEAR peuvent être
+ librement mélangés avec ceux de SimpleTest
+ mais vous ne pouvez pas utiliser les assertions
+ de SimpleTest au sein des versions héritées
+ des scénarios de test. La raison ?
+ Une simple vérification que vous ne rendez pas
+ par accident vos scénarios de test complètement
+ dépendants de SimpleTest.
+ Peut-être que vous souhaitez publier
+ votre bibliothèque sur PEAR par exemple :
+ ça voudrait dire la livrer avec des scénarios de
+ test compatibles avec PEAR::PhpUnit.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/index.html b/vendors/simpletest/docs/fr/index.html
new file mode 100644
index 000000000..a13cb5787
--- /dev/null
+++ b/vendors/simpletest/docs/fr/index.html
@@ -0,0 +1,572 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>
+ Prise en main rapide de SimpleTest pour PHP -
+ Tests unitaire et objets fantaisie pour PHP
+ </title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Prise en main rapide de SimpleTest</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#unit">Utiliser le testeur rapidement</a>
+ avec un exemple.
+ </li>
+<li>
+ <a href="#group">Groupes de tests</a>
+ pour tester en un seul clic.
+ </li>
+<li>
+ <a href="#mock">Utiliser les objets fantaisie</a>
+ pour faciliter les tests et gagner en contrôle.
+ </li>
+<li>
+ <a href="#web">Tester des pages web</a>
+ au niveau de l'HTML.
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ Le présent article présuppose que vous soyez familier avec
+ le concept de tests unitaires ainsi que celui de développement
+ web avec le langage PHP. Il s'agit d'un guide pour le nouvel
+ et impatient utilisateur de
+ <a href="https://sourceforge.net/project/showfiles.php?group_id=76550">SimpleTest</a>.
+ Pour une documentation plus complète, particulièrement si
+ vous découvrez les tests unitaires, consultez la
+ <a href="http://www.lastcraft.com/unit_test_documentation.php">documentation
+ en cours</a>, et pour des exemples de scénarios de test,
+ consultez le
+ <a href="http://www.lastcraft.com/first_test_tutorial.php">tutorial
+ sur les tests unitaires</a>.
+ </p>
+
+ <p><a class="target" name="unit"><h2>Utiliser le testeur rapidement</h2></a></p>
+ <p>
+ Parmi les outils de test pour logiciel, le testeur unitaire
+ est le plus proche du développeur. Dans un contexte de
+ développement agile, le code de test se place juste à côté
+ du code source étant donné que tous les deux sont écrits
+ simultanément. Dans ce contexte, SimpleTest aspire à être
+ une solution complète de test pour un développeur PHP et
+ s'appelle "Simple" parce qu'elle devrait être simple à
+ utiliser et à étendre. Ce nom n'était pas vraiment un bon
+ choix. Non seulement cette solution inclut toutes les
+ fonctions classiques qu'on est en droit d'attendre de la
+ part des portages de <a href="http://www.junit.org/">JUnit</a> et des <a href="http://sourceforge.net/projects/phpunit/">PHPUnit</a>,
+ mais elle inclut aussi les <a href="http://www.mockobjects.com/">objets fantaisie ou
+ "mock objects"</a>.
+ </p>
+ <p>
+ Ce qui rend cet outil immédiatement utile pour un développeur PHP,
+ c'est son navigateur web interne.
+ Il permet des tests qui parcourent des sites web, remplissent
+ des formulaires et testent le contenu des pages.
+ Etre capable d'écrire ces tests en PHP veut dire qu'il devient
+ facile d'écrire des tests de recette (ou d'intégration).
+ Un exemple serait de confirmer qu'un utilisateur a bien été ajouté
+ dans une base de données après s'être enregistré sur une site web.
+ </p>
+ <p>
+ La démonstration la plus rapide : l'exemple
+ </p>
+ <p>
+ Supposons que nous sommes en train de tester une simple
+ classe de log dans un fichier : elle s'appelle
+ <span class="new_code">Log</span> dans <em>classes/Log.php</em>. Commençons
+ par créer un script de test, appelé
+ <em>tests/log_test.php</em>. Son contenu est le suivant...
+<pre>
+&lt;?php
+<strong>require_once('simpletest/autorun.php');</strong>
+require_once('../classes/log.php');
+
+class TestOfLogging extends <strong>UnitTestCase</strong> {
+}
+?&gt;
+</pre>
+ Ici le répertoire <em>simpletest</em> est soit dans le
+ dossier courant, soit dans les dossiers pour fichiers
+ inclus. Vous auriez à éditer ces arborescences suivant
+ l'endroit où vous avez installé SimpleTest.
+ Le fichier "autorun.php" fait plus que juste inclure
+ les éléments de SimpleTest : il lance aussi les tests pour nous.
+ </p>
+ <p>
+ <span class="new_code">TestOfLogging</span> est notre premier scénario de test
+ et il est pour l'instant vide.
+ Chaque scénario de test est une classe qui étend une des classes
+ de base de SimpleTest. Nous pouvons avoir autant de classes de ce type
+ que nous voulons.
+ </p>
+ <p>
+ Avec ces trois lignes d'échafaudage
+ l'inclusion de notre classe <span class="new_code">Log</span>, nous avons une suite
+ de tests. Mais pas encore de test !
+ </p>
+ <p>
+ Pour notre premier test, supposons que la classe <span class="new_code">Log</span>
+ prenne le nom du fichier à écrire au sein du constructeur,
+ et que nous avons un répertoire temporaire dans lequel placer
+ ce fichier.
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('../classes/log.php');
+
+class TestOfLogging extends UnitTestCase {
+ function <strong>testLogCreatesNewFileOnFirstMessage()</strong> {
+ @unlink('/temp/test.log');
+ $log = new Log('/temp/test.log');
+ <strong>$this-&gt;assertFalse(file_exists('/temp/test.log'));</strong>
+ $log-&gt;message('Should write this to a file');
+ <strong>$this-&gt;assertTrue(file_exists('/temp/test.log'));</strong>
+ }
+}
+?&gt;
+</pre>
+ Au lancement du scénario de test, toutes les méthodes qui
+ commencent avec la chaîne <span class="new_code">test</span> sont
+ identifiées puis exécutées.
+ Si la méthode commence par <span class="new_code">test</span>, c'est un test.
+ Remarquez bien le nom très long de notre exemple :
+ <span class="new_code">testLogCreatesNewFileOnFirstMessage()</span>.
+ C'est bel et bien délibéré : ce style est considéré désirable
+ et il rend la sortie du test plus lisible.
+ </p>
+ <p>
+ D'ordinaire nous avons bien plusieurs méthodes de tests.
+ Mais ce sera pour plus tard.
+ </p>
+ <p>
+ Les assertions dans les
+ méthodes de test envoient des messages vers le framework de
+ test qui affiche immédiatement le résultat. Cette réponse
+ immédiate est importante, non seulement lors d'un crash
+ causé par le code, mais aussi de manière à rapprocher
+ l'affichage de l'erreur au plus près du scénario de test
+ concerné via un appel à <span class="new_code">print</span>code&gt;.
+ </p>
+ <p>
+ Pour voir ces résultats lançons effectivement les tests.
+ Aucun autre code n'est nécessaire, il suffit d'ouvrir
+ la page dans un navigateur.
+ </p>
+ <p>
+ En cas échec, l'affichage ressemble à...
+ <div class="demo">
+ <h1>TestOfLogging</h1>
+ <span class="fail">Fail</span>: testcreatingnewfile-&gt;True assertion failed.<br>
+ <div style="padding: 8px; margin-top: 1em; background-color: red; color: white;">1/1 test cases complete.
+ <strong>1</strong> passes and <strong>1</strong> fails.</div>
+ </div>
+ ...et si ça passe, on obtient...
+ <div class="demo">
+ <h1>TestOfLogging</h1>
+ <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">1/1 test cases complete.
+ <strong>2</strong> passes and <strong>0</strong> fails.</div>
+ </div>
+ Et si vous obtenez ça...
+ <div class="demo">
+ <b>Fatal error</b>: Failed opening required '../classes/log.php' (include_path='') in <b>/home/marcus/projects/lastcraft/tutorial_tests/Log/tests/log_test.php</b> on line <b>7</b>
+ </div>
+ c'est qu'il vous manque le fichier <em>classes/Log.php</em>
+ qui pourrait ressembler à :
+<pre>
+&lt;?php<strong>
+class Log {
+ function Log($file_path) {
+ }
+
+ function message() {
+ }
+}</strong>
+?&gt;
+</pre>
+ C'est largement plus sympathique d'écrire le code après le test.
+ Plus que sympatique même - cette technique s'appelle
+ "Développement Piloté par les Tests" ou
+ "Test Driven Development" en anglais.
+ </p>
+ <p>
+ Pour plus de renseignements sur le testeur, voyez la
+ <a href="unit_test_documentation.html">documentation pour les tests de régression</a>.
+ </p>
+
+ <p><a class="target" name="group"><h2>Construire des groupes de tests</h2></a></p>
+ <p>
+ Il est peu probable que dans une véritable application on
+ ait uniquement besoin de passer un seul scénario de test.
+ Cela veut dire que nous avons besoin de grouper les
+ scénarios dans un script de test qui peut, si nécessaire,
+ lancer tous les tests de l'application.
+ </p>
+ <p>
+ Notre première étape est de créer un nouveau fichier appelé
+ <em>tests/all_tests.php</em> et d'y inclure le code suivant...
+<pre>
+&lt;?php
+<strong>require_once('simpletest/autorun.php');</strong>
+
+class AllTests extends <strong>TestSuite</strong> {
+ function AllTests() {
+ $this-&gt;TestSuite(<strong>'All tests'</strong>);
+ <strong>$this-&gt;addFile('log_test.php');</strong>
+ }
+}
+?&gt;
+</pre>
+ L'inclusion de "autorun" permettra à notre future suite
+ de tests d'être lancée juste en invoquant ce script.
+ </p>
+ <p>
+ La sous-classe <span class="new_code">TestSuite</span> doit chaîner
+ son constructeur. Cette limitation sera supprimée dans
+ les versions à venir.
+ </p>
+ <p>
+ The method <span class="new_code">TestSuite::addFile()</span>
+ will include the test case file and read any new classes
+ that are descended from <span class="new_code">SimpleTestCase</span>.
+
+ Cette méthode <span class="new_code">TestSuite::addTestFile()</span> va
+ inclure le fichier de scénarios de test et lire parmi
+ toutes les nouvelles classes créées celles qui sont issues
+ de <span class="new_code">SimpleTestCase</span>.
+ <span class="new_code">UnitTestCase</span> est juste un exemple de classe dérivée
+ depuis <span class="new_code">SimpleTestCase</span> et vous pouvez créer les vôtres.
+ <span class="new_code">TestSuite::addFile()</span> peut aussi inclure d'autres suites.
+ </p>
+ <p>
+ La classe ne sera pas encore instanciée.
+ Quand la suite de tests est lancée, elle construira chaque instance
+ une fois le test atteint, et le détuira juste ensuite.
+ Cela veut dire que le constructeur n'est lancé qu'une fois avant
+ chaque initialisation de ce scénario de test et que le destructeur
+ est lui aussi lancé avant que le test suivant ne commence.
+ </p>
+ <p>
+ Il est commun de grouper des scénarios de test dans des super-classes
+ qui ne sont pas sensées être lancées, mais qui deviennent une classe de base
+ pour d'autres tests.
+ Pour que "autorun" fonctionne proprement les fichiers
+ des scénarios de test ne devraient pas lancer aveuglement
+ d'autres extensions de scénarios de test qui ne lanceraient pas
+ effectivement des tests.
+ Cela pourrait aboutir à un mauvais comptages des scénarios de test
+ pendant la procédure.
+ Pas vraiement un problème majeure, mais pour éviter cet inconvénient
+ il suffit de marquer vos classes de base comme <span class="new_code">abstract</span>.
+ SimpleTest ne lance pas les classes abstraites. Et si vous utilisez encore
+ PHP4 alors une directive <span class="new_code">SimpleTestOptions::ignore()</span>
+ dans votre fichier de scénario de test aura le même effet.
+ </p>
+ <p>
+ Par ailleurs, le fichier avec le scénario de test ne devrait pas
+ avoir été inclus ailleurs. Sinon aucun scénario de test
+ ne sera inclus à ce groupe.
+ Ceci pourrait se transformer en un problème plus grave :
+ si des fichiers ont déjà été inclus par PHP alors la méthode
+ <span class="new_code">TestSuite::addFile()</span> ne les détectera pas.
+ </p>
+ <p>
+ Pour afficher les résultats, il est seulement nécessaire
+ d'invoquer <em>tests/all_tests.php</em> à partir du serveur
+ web.
+ </p>
+ <p>
+ Pour plus de renseignements des groupes de tests, voyez le
+ <a href="group_test_documentation.html">documentation sur le groupement des tests</a>.
+ </p>
+
+ <p><a class="target" name="mock"><h2>Utiliser les objets fantaisie</h2></a></p>
+ <p>
+ Avançons un peu plus dans le futur.
+ </p>
+ <p>
+ Supposons que notre class logging soit testée et terminée.
+ Supposons aussi que nous testons une autre classe qui ait
+ besoin d'écrire des messages de log, disons
+ <span class="new_code">SessionPool</span>. Nous voulons tester une méthode
+ qui ressemblera probablement à quelque chose comme...
+<pre><strong>
+class SessionPool {
+ ...
+ function logIn($username) {
+ ...
+ $this-&gt;_log-&gt;message('User $username logged in.');
+ ...
+ }
+ ...
+}
+</strong>
+</pre>
+ Avec le concept de "réutilisation de code" comme fil
+ conducteur, nous utilisons notre class <span class="new_code">Log</span>. Un
+ scénario de test classique ressemblera peut-être à...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('../classes/log.php');
+<strong>require_once('../classes/session_pool.php');</strong>
+
+class <strong>TestOfSessionLogging</strong> extends UnitTestCase {
+
+ function setUp() {
+ <strong>@unlink('/temp/test.log');</strong>
+ }
+
+ function tearDown() {
+ <strong>@unlink('/temp/test.log');</strong>
+ }
+
+ function testLoggingInIsLogged() {
+ <strong>$log = new Log('/temp/test.log');
+ $session_pool = &amp;new SessionPool($log);
+ $session_pool-&gt;logIn('fred');</strong>
+ $messages = file('/temp/test.log');
+ $this-&gt;assertEqual($messages[0], "User fred logged in.<strong>\n</strong>");
+ }
+}
+?&gt;
+</pre>
+ Nous expliquerons les méthodes <span class="new_code">setUp()</span>
+ et <span class="new_code">tearDown()</span> plus tard.
+ </p>
+ <p>
+ Le design de ce scénario de test n'est pas complètement
+ mauvais, mais on peut l'améliorer. Nous passons du temps à
+ tripoter les fichiers de log qui ne font pas partie de
+ notre test.
+ Pire, nous avons créé des liens de proximité
+ entre la classe <span class="new_code">Log</span> et ce test. Que se
+ passerait-il si nous n'utilisions plus de fichiers, mais la
+ bibliothèque <em>syslog</em> à la place ?
+
+ Cela veut dire que notre test <span class="new_code">TestOfSessionLogging</span>
+ enverra un échec alors même qu'il ne teste pas Logging.
+ </p>
+ <p>
+ Il est aussi fragile sur des petites retouches. Avez-vous
+ remarqué le retour chariot supplémentaire à la fin du
+ message ? A-t-il été ajouté par le loggueur ? Et si il
+ ajoutait aussi un timestamp ou d'autres données ?
+ </p>
+ <p>
+ L'unique partie à tester réellement est l'envoi d'un
+ message précis au loggueur.
+ Nous pouvons réduire le couplage en
+ créant une fausse classe de logging : elle ne fait
+ qu'enregistrer le message pour le test, mais ne produit
+ aucun résultat. Sauf qu'elle doit ressembler exactement à
+ l'original.
+ </p>
+ <p>
+ Si l'objet fantaisie n'écrit pas dans un fichier alors nous
+ nous épargnons la suppression du fichier avant et après le
+ test. Nous pourrions même nous épargner quelques lignes de
+ code supplémentaires si l'objet fantaisie pouvait exécuter
+ l'assertion.
+ <p>
+ </p>
+ Trop beau pour être vrai ? Pas vraiement on peut créer un tel
+ objet très facilement...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('../classes/log.php');
+require_once('../classes/session_pool.php');
+
+<strong>Mock::generate('Log');</strong>
+
+class TestOfSessionLogging extends UnitTestCase {
+
+ function testLoggingInIsLogged() {<strong>
+ $log = &amp;new MockLog();
+ $log-&gt;expectOnce('message', array('User fred logged in.'));</strong>
+ $session_pool = &amp;new SessionPool(<strong>$log</strong>);
+ $session_pool-&gt;logIn('fred');
+ }
+}
+?&gt;
+</pre>
+ L'appel <span class="new_code">Mock::generate()</span> a généré
+ une nouvelle classe appelé <span class="new_code">MockLog</span>.
+ Cela ressemble à un clone identique, sauf que nous pouvons
+ y adjoindre du code de test.
+ C'est ce que fait <span class="new_code">expectOnce()</span>.
+ Cela dit que si <span class="new_code">message()</span> m'est appelé,
+ il a intérêt à l'être avec le paramètre
+ "User fred logged in.".
+ </p>
+ <p>
+ L'appel <span class="new_code">tally()</span> est nécessaire pour annoncer à
+ l'objet fantaisie qu'il n'y aura plus d'appels ultérieurs.
+ Sans ça l'objet fantaisie pourrait attendre pendant une
+ éternité l'appel de la méthode sans jamais prévenir le
+ scénario de test. Les autres tests sont déclenchés
+ automatiquement quand l'appel à <span class="new_code">message()</span> est
+ invoqué sur l'objet <span class="new_code">MockLog</span> par le code
+ <span class="new_code">SessionPool::logIn()</span>.
+ L'appel <span class="new_code">mock</span> va déclencher une comparaison des
+ paramètres et ensuite envoyer le message "pass" ou "fail"
+ au test pour l'affichage. Des jokers peuvent être inclus
+ pour ne pas avoir à tester tous les paramètres d'un appel
+ alors que vous ne souhaitez qu'en tester un.
+ </p>
+ <p>
+ Les objets fantaisie dans la suite SimpleTest peuvent avoir
+ un ensemble de valeurs de sortie arbitraires, des séquences
+ de sorties, des valeurs de sortie sélectionnées à partir
+ des arguments d'entrée, des séquences de paramètres
+ attendus et des limites sur le nombre de fois qu'une
+ méthode peut être invoquée.
+ </p>
+ <p>
+ Pour que ce test fonctionne la librairie avec les objets
+ fantaisie doit être incluse dans la suite de tests, par
+ exemple dans <em>all_tests.php</em>.
+ </p>
+ <p>
+ Pour plus de renseignements sur les objets fantaisie, voyez le
+ <a href="mock_objects_documentation.html">documentation sur les objets fantaisie</a>.
+ </p>
+
+ <p><a class="target" name="web"><h2>Tester une page web</h2></a></p>
+ <p>
+ Une des exigences des sites web, c'est qu'ils produisent
+ des pages web. Si vous construisez un projet de A à Z et
+ que vous voulez intégrer des tests au fur et à mesure alors
+ vous voulez un outil qui puisse effectuer une navigation
+ automatique et en examiner le résultat. C'est le boulot
+ d'un testeur web.
+ </p>
+ <p>
+ Effectuer un test web via SimpleTest reste assez primitif :
+ il n'y a pas de javascript par exemple.
+ La plupart des autres opérations d'un navigateur sont simulées.
+ </p>
+ <p>
+ Pour vous donner une idée, voici un exemple assez trivial :
+ aller chercher une page web,
+ à partir de là naviguer vers la page "about"
+ et finalement tester un contenu déterminé par le client.
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+<strong>require_once('simpletest/web_tester.php');</strong>
+
+class TestOfAbout extends <strong>WebTestCase</strong> {
+ function testOurAboutPageGivesFreeReignToOurEgo() {
+ <strong>$this-&gt;get('http://test-server/index.php');
+ $this-&gt;click('About');
+ $this-&gt;assertTitle('About why we are so great');
+ $this-&gt;assertText('We are really great');</strong>
+ }
+}
+?&gt;
+</pre>
+ Avec ce code comme test de recette, vous pouvez vous
+ assurer que le contenu corresponde toujours aux
+ spécifications à la fois des développeurs et des autres
+ parties prenantes au projet.
+ </p>
+ <p>
+ Vous pouvez aussi naviguer à travers des formulaires...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');
+require_once('simpletest/web_tester.php');
+
+class TestOfRankings extends WebTestCase {
+ function testWeAreTopOfGoogle() {
+ $this-&gt;get('http://google.com/');
+ $this-&gt;setField('q', 'simpletest');
+ $this-&gt;click("I'm Feeling Lucky");
+ $this-&gt;assertTitle('SimpleTest - Unit Testing for PHP');
+ }
+}
+?&gt;
+</pre>
+ ...même si cela pourrait constituer une violation
+ des documents juridiques de Google(tm).
+ </p>
+ <p>
+ Pour plus de renseignements sur comment tester une page web, voyez la
+ <a href="web_tester_documentation.html">documentation sur tester des scripts web</a>.
+ </p>
+ <p>
+ <a href="http://sourceforge.net/projects/simpletest/"><img src="http://sourceforge.net/sflogo.php?group_id=76550&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo"></a>
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ <a href="https://sourceforge.net/project/showfiles.php?group_id=76550&amp;release_id=153280">Télécharger PHP Simple Test</a>
+ depuis <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ L'<a href="http://simpletest.org/api/">API de SimpleTest pour développeur</a>
+ donne tous les détails sur les classes et assertions existantes.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/mock_objects_documentation.html b/vendors/simpletest/docs/fr/mock_objects_documentation.html
new file mode 100644
index 000000000..c03ac611f
--- /dev/null
+++ b/vendors/simpletest/docs/fr/mock_objects_documentation.html
@@ -0,0 +1,778 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : les objets fantaise</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur les objets fantaisie</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#quoi">Que sont les objets fantaisie ?</a>
+ </li>
+<li>
+ <a href="#creation">Créer des objets fantaisie</a>.
+ </li>
+<li>
+ <a href="#bouchon">L'objet fantaisie - acteur</a> ou bouchon.
+ </li>
+<li>
+ <a href="#attentes">L'objet fantaisie - critique</a> avec des attentes.
+ </li>
+<li>
+ <a href="#approches">D'autres approches</a>
+ y compris des librairies d'objets fantaisie.
+ </li>
+<li>
+ Utiliser les objets fantaisie avec
+ <a href="#autres_testeurs">d'autres testeurs unitaires</a>.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="quoi"><h2>Que sont les objets fantaisie ?</h2></a></p>
+ <p>
+ Les objets fantaisie - ou "mock objects" en anglais -
+ ont deux rôles pendant un scénario de test : acteur et critique.
+ </p>
+ <p>
+ Le comportement d'acteur est celui de simuler
+ des objets difficiles à initialiser ou trop consommateurs
+ en temps pendant un test.
+ Le cas classique est celui de la connexion à une base de données.
+ Mettre sur pied une base de données de test au lancement
+ de chaque test ralentirait considérablement les tests
+ et en plus exigerait l'installation d'un moteur
+ de base de données ainsi que des données sur la machine de test.
+ Si nous pouvons simuler la connexion
+ et renvoyer des données à notre guise
+ alors non seulement nous gagnons en pragmatisme
+ sur les tests mais en sus nous pouvons nourrir
+ notre base avec des données falsifiées
+ et voir comment il répond. Nous pouvons
+ simuler une base de données en suspens ou
+ d'autres cas extrêmes sans avoir à créer
+ une véritable panne de base de données.
+ En d'autres termes nous pouvons gagner
+ en contrôle sur l'environnement de test.
+ </p>
+ <p>
+ Si les objets fantaisie ne se comportaient que comme
+ des acteurs alors on les connaîtrait sous le nom de
+ <a href="server_stubs_documentation.html">bouchons serveur</a>.
+ </p>
+ <p>
+ Cependant non seulement les objets fantaisie jouent
+ un rôle (en fournissant à la demande les valeurs requises)
+ mais en plus ils sont aussi sensibles aux messages qui
+ leur sont envoyés (par le biais d'attentes).
+ En posant les paramètres attendus d'une méthode
+ ils agissent comme des gardiens :
+ un appel sur eux doit être réalisé correctement.
+ Si les attentes ne sont pas atteintes ils nous épargnent
+ l'effort de l'écriture d'une assertion de test avec
+ échec en réalisant cette tâche à notre place.
+ Dans le cas d'une connexion à une base de données
+ imaginaire ils peuvent tester si la requête, disons SQL,
+ a bien été formé par l'objet qui utilise cette connexion.
+ Mettez-les sur pied avec des attentes assez précises
+ et vous verrez que vous n'aurez presque plus d'assertion à écrire manuellement.
+ </p>
+
+ <p><a class="target" name="creation"><h2>Créer des objets fantaisie</h2></a></p>
+ <p>
+ Comme pour la création des bouchons serveur, tout ce dont
+ nous avons besoin c'est d'un classe existante.
+ La fameuse connexion à une base de données qui ressemblerait à...
+<pre>
+<strong>class DatabaseConnection {
+ function DatabaseConnection() {
+ }
+
+ function query() {
+ }
+
+ function selectQuery() {
+ }
+}</strong>
+</pre>
+ Cette classe n'a pas encore besoin d'être implémentée.
+ Pour en créer sa version fantaisie nous devons juste
+ inclure la librairie d'objet fantaisie puis lancer le générateur...
+<pre>
+<strong>require_once('simpletest/unit_tester.php');
+require_once('simpletest/mock_objects.php');
+require_once('database_connection.php');
+
+Mock::generate('DatabaseConnection');</strong>
+</pre>
+ Ceci génère une classe clone appelée <span class="new_code">MockDatabaseConnection</span>.
+ Nous pouvons désormais créer des instances de
+ cette nouvelle classe à l'intérieur même de notre scénario de test...
+<pre>
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/mock_objects.php');
+require_once('database_connection.php');
+
+Mock::generate('DatabaseConnection');
+<strong>
+class MyTestCase extends UnitTestCase {
+
+ function testSomething() {
+ $connection = &amp;new MockDatabaseConnection($this);
+ }
+}</strong>
+</pre>
+ Contrairement aux bouchons, le constructeur
+ d'une classe fantaisie a besoin d'une référence au scénario
+ de test pour pouvoir transmettre les succès
+ et les échecs pendant qu'il vérifie les attentes.
+ Concrètement ça veut dire que les objets fantaisie
+ ne peuvent être utilisés qu'au sein d'un scénario de test.
+ Malgré tout, cette puissance supplémentaire implique
+ que les bouchons ne sont que rarement utilisés
+ si des objets fantaisie sont disponibles.
+ </p>
+
+ <p><a class="target" name="bouchon"><h2>Objets fantaisie en action</h2></a></p>
+ <p>
+ La version fantaisie d'une classe contient
+ toutes les méthodes de l'originale.
+ De la sorte une opération comme
+ <span class="new_code">$connection-&gt;query()</span>
+ est encore possible.
+ Tout comme avec les bouchons, nous pouvons remplacer
+ la valeur nulle renvoyée par défaut...
+<pre>
+<strong>$connection-&gt;setReturnValue('query', 37);</strong>
+</pre>
+ Désormais à chaque appel de
+ <span class="new_code">$connection-&gt;query()</span>
+ nous recevons comme résultat 37.
+ Tout comme avec les bouchons nous pouvons utiliser
+ des jokers et surcharger le paramètre joker.
+ Nous pouvons aussi ajouter des méthodes supplémentaires
+ à l'objet fantaisie lors de sa génération
+ et lui choisir un nom de classe qui lui soit propre...
+<pre>
+<strong>Mock::generate('DatabaseConnection', 'MyMockDatabaseConnection', array('setOptions'));</strong>
+</pre>
+ Ici l'objet fantaisie se comportera comme
+ si <span class="new_code">setOptions()</span> existait dans la classe originale.
+ C'est pratique si une classe a utilisé le mécanisme
+ <span class="new_code">overload()</span> de PHP pour ajouter des méthodes dynamiques.
+ Vous pouvez créer des fantaisies spéciales pour simuler cette situation.
+ </p>
+ <p>
+ Tous les modèles disponibles avec les bouchons serveur
+ le sont également avec les objets fantaisie...
+<pre>
+class Iterator {
+ function Iterator() {
+ }
+
+ function next() {
+ }
+}
+</pre>
+ Une nouvelle fois, supposons que cet itérateur
+ ne retourne que du texte jusqu'au moment où il atteint
+ son terme, quand il renvoie <span class="new_code">false</span>.
+ Nous pouvons le simuler avec...
+<pre>
+Mock::generate('Iterator');
+
+class IteratorTest extends UnitTestCase() {
+
+ function testASequence() {<strong>
+ $iterator = &amp;new MockIterator($this);
+ $iterator-&gt;setReturnValue('next', false);
+ $iterator-&gt;setReturnValueAt(0, 'next', 'First string');
+ $iterator-&gt;setReturnValueAt(1, 'next', 'Second string');</strong>
+ ...
+ }
+}
+</pre>
+ Au moment du premier appel à <span class="new_code">next()</span>
+ sur l'itérateur fantaisie il renverra tout d'abord
+ "First string", puis ce sera au tour de
+ "Second string" au deuxième appel
+ et ensuite pour tout appel suivant <span class="new_code">false</span>
+ sera renvoyé.
+ Ces valeurs renvoyées successivement sont prioritaires
+ sur la valeur constante retournée.
+ Cette dernière est un genre de valeur par défaut si vous voulez.
+ </p>
+ <p>
+ Reprenons aussi le conteneur d'information bouchonné
+ avec des pairs clef / valeur...
+<pre>
+class Configuration {
+ function Configuration() {
+ }
+
+ function getValue($key) {
+ }
+}
+</pre>
+ Il s'agit là d'une situation classique
+ d'utilisation d'objets fantaisie étant donné
+ que la configuration peut varier grandement de machine à machine :
+ ça contraint fortement la fiabilité de nos tests
+ si nous l'utilisons directement.
+ Le problème est que toutes les données nous parviennent
+ à travers la méthode <span class="new_code">getValue()</span>
+ et que nous voulons des résultats différents pour des clefs différentes.
+ Heureusement les objets fantaisie ont un système de filtrage...
+<pre>
+<strong>$config = &amp;new MockConfiguration($this);
+$config-&gt;setReturnValue('getValue', 'primary', array('db_host'));
+$config-&gt;setReturnValue('getValue', 'admin', array('db_user'));
+$config-&gt;setReturnValue('getValue', 'secret', array('db_password'));</strong>
+</pre>
+ Le paramètre en plus est une liste d'arguments
+ à faire correspondre. Dans ce cas nous essayons
+ de faire correspondre un unique argument :
+ en l'occurrence la clef recherchée.
+ Maintenant que la méthode <span class="new_code">getValue()</span>
+ est invoquée sur l'objet fantaisie...
+<pre>
+$config-&gt;getValue('db_user')
+</pre>
+ ...elle renverra "admin".
+ Elle le trouve en essayant de faire correspondre
+ les arguments entrants dans sa liste
+ d'arguments sortants les uns après les autres
+ jusqu'au moment où une correspondance exacte est atteinte.
+ </p>
+ <p>
+ Il y a des fois où vous souhaitez
+ qu'un objet spécifique soit servi par la fantaisie
+ plutôt qu'une copie.
+ De nouveau c'est identique au mécanisme des bouchons serveur...
+<pre>
+class Thing {
+}
+
+class Vector {
+ function Vector() {
+ }
+
+ function get($index) {
+ }
+}
+</pre>
+ Dans ce cas vous pouvez placer une référence
+ dans la liste renvoyée par l'objet fantaisie...
+<pre>
+$thing = new Thing();<strong>
+$vector = &amp;new MockVector($this);
+$vector-&gt;setReturnReference('get', $thing, array(12));</strong>
+</pre>
+ Avec cet arrangement vous savez qu'à chaque appel
+ de <span class="new_code">$vector-&gt;get(12)</span>
+ le même <span class="new_code">$thing</span> sera renvoyé.
+ </p>
+
+ <p><a class="target" name="attentes"><h2>Objets fantaisie en critique</h2></a></p>
+ <p>
+ Même si les bouchons serveur vous isolent
+ du désordre du monde réel, il ne s'agit là que
+ de la moitié du bénéfice potentiel.
+ Vous pouvez avoir une classe de test recevant
+ les messages ad hoc, mais est-ce que votre nouvelle classe
+ renvoie bien les bons ?
+ Le tester peut devenir cafouillis sans une librairie d'objets fantaisie.
+ </p>
+ <p>
+ Pour l'exemple, prenons une classe <span class="new_code">SessionPool</span>
+ à laquelle nous allons ajouter une fonction de log.
+ Plutôt que de complexifier la classe originale,
+ nous souhaitons ajouter ce comportement avec un décorateur (GOF).
+ Pour l'instant le code de <span class="new_code">SessionPool</span> ressemble à...
+<pre>
+<strong>class SessionPool {
+ function SessionPool() {
+ ...
+ }
+
+ function &amp;findSession($cookie) {
+ ...
+ }
+ ...
+}
+
+class Session {
+ ...
+}</strong>
+
+</pre>
+ Alors que pour notre code de log, nous avons...
+<pre><strong>
+class Log {
+ function Log() {
+ ...
+ }
+
+ function message() {
+ ...
+ }
+}
+
+class LoggingSessionPool {
+ function LoggingSessionPool(&amp;$session_pool, &amp;$log) {
+ ...
+ }
+
+ function &amp;findSession($cookie) {
+ ...
+ }
+ ...
+}</strong>
+</pre>
+ Dans tout ceci, la seule classe à tester est
+ <span class="new_code">LoggingSessionPool</span>. En particulier,
+ nous voulons vérifier que la méthode <span class="new_code">findSession()</span>
+ est appelée avec le bon identifiant de session au sein du cookie
+ et qu'elle renvoie bien le message "Starting session $cookie"
+ au loggueur.
+ </p>
+ <p>
+ Bien que nous ne testions que quelques lignes
+ de code de production, voici la liste des choses
+ à faire dans un scénario de test conventionnel :
+ <ol>
+ <li>Créer un objet de log.</li>
+ <li>Indiquer le répertoire d'écriture du fichier de log.</li>
+ <li>Modifier les droits sur le répertoire pour pouvoir y écrire le fichier.</li>
+ <li>Créer un objet <span class="new_code">SessionPool</span>.</li>
+ <li>Lancer une session, ce qui demande probablement pas mal de choses.</li>
+ <li>Invoquer <span class="new_code">findSession()</span>.</li>
+ <li>Lire le nouvel identifiant de session (en espérant qu'il existe un accesseur !).</li>
+ <li>Lever une assertion de test pour vérifier que cet identifiant correspond bien au cookie.</li>
+ <li>Lire la dernière ligne du fichier de log.</li>
+ <li>Supprimer avec une (ou plusieurs) expression rationnelle les timestamps de log en trop, etc.</li>
+ <li>Vérifier que le message de session est bien dans le texte.</li>
+ </ol>
+ Pas étonnant que les développeurs détestent
+ écrire des tests quand ils sont aussi ingrats.
+ Pour rendre les choses encore pire, à chaque fois que
+ le format de log change ou bien que la méthode de création
+ des sessions change, nous devons réécrire une partie
+ des tests alors même qu'ils ne testent pas ces parties
+ du système. Nous sommes en train de préparer
+ le cauchemar pour les développeurs de ces autres classes.
+ </p>
+ <p>
+ A la place, voici la méthode complète pour le test
+ avec un peu de magie via les objets fantaisie...
+<pre>
+Mock::generate('Session');
+Mock::generate('SessionPool');
+Mock::generate('Log');
+
+class LoggingSessionPoolTest extends UnitTestCase {
+ ...
+ function testFindSessionLogging() {<strong>
+ $session = &amp;new MockSession($this);
+ $pool = &amp;new MockSessionPool($this);
+ $pool-&gt;setReturnReference('findSession', $session);
+ $pool-&gt;expectOnce('findSession', array('abc'));
+
+ $log = &amp;new MockLog($this);
+ $log-&gt;expectOnce('message', array('Starting session abc'));
+
+ $logging_pool = &amp;new LoggingSessionPool($pool, $log);
+ $this-&gt;assertReference($logging_pool-&gt;findSession('abc'), $session);
+ $pool-&gt;tally();
+ $log-&gt;tally();</strong>
+ }
+}
+</pre>
+ Commençons par écrire une session simulacre.
+ Pas la peine d'être trop pointilleux avec
+ celle-ci puisque la vérification de la session
+ désirée est effectuée ailleurs. Nous avons
+ juste besoin de vérifier qu'il s'agit de
+ la même que celle qui vient du groupe commun des sessions.
+ </p>
+ <p>
+ <span class="new_code">findSession()</span> est un méthode fabrique
+ dont la simulation est décrite <a href="#stub">plus haut</a>.
+ Le point de départ vient avec le premier appel
+ <span class="new_code">expectOnce()</span>. Cette ligne indique
+ qu'à chaque fois que <span class="new_code">findSession()</span>
+ est invoqué sur l'objet fantaisie, il vérifiera
+ les arguments entrant. S'il ne reçoit
+ que la chaîne "abc" en tant qu'argument
+ alors un succès est envoyé au testeur unitaire,
+ sinon c'est un échec qui est généré.
+ Il s'agit là de la partie qui teste si nous avons bien
+ la bonne session. La liste des arguments suit
+ une format identique à celui qui précise les valeurs renvoyées.
+ Vous pouvez avoir des jokers et des séquences
+ et l'ordre de l'évaluation restera le même.
+ </p>
+ <p>
+ Si l'appel n'est jamais effectué alors n'est généré
+ ni le succès, ni l'échec. Pour contourner cette limitation,
+ nous devons dire à l'objet fantaisie que le test est terminé :
+ il pourra alors décider si les attentes ont été répondues.
+ L'assertion du testeur unitaire de ceci est déclenchée
+ par l'appel <span class="new_code">tally()</span> à la fin du test.
+ </p>
+ <p>
+ Nous utilisons le même modèle pour mettre sur pied
+ le loggueur fantaisie. Nous lui indiquons que <span class="new_code">message()</span>
+ devrait être invoqué une fois et une fois seulement
+ avec l'argument "Starting session abc".
+ En testant les arguments d'appel, plutôt que ceux de sortie du loggueur,
+ nous isolons le test de tout modification dans le loggueur.
+ </p>
+ <p>
+ Nous commençons le lancement nos tests à la création
+ du nouveau <span class="new_code">LoggingSessionPool</span>
+ et nous l'alimentons avec nos objets fantaisie juste créés.
+ Désormais tout est sous contrôle. Au final nous confirmons
+ que le <span class="new_code">$session</span> donné au décorateur est bien
+ celui reçu et prions les objets fantaisie de lancer leurs
+ tests de comptage d'appel interne avec les appels <span class="new_code">tally()</span>.
+ </p>
+ <p>
+ Il y a encore pas mal de code de test, mais ce code est très strict.
+ S'il vous semble encore terrifiant il l'est bien moins
+ que si nous avions essayé sans les objets fantaisie
+ et ce test en particulier, interactions plutôt que résultat,
+ est toujours plus difficile à mettre en place.
+ Le plus souvent vous aurez besoin de tester des situations
+ plus complexes sans ce niveau ni cette précision.
+ En outre une partie peut être remaniée avec la méthode
+ de scénario de test <span class="new_code">setUp()</span>.
+ </p>
+ <p>
+ Voici la liste complète des attentes que vous pouvez
+ placer sur un objet fantaisie avec
+ <a href="http://www.lastcraft.com/simple_test.php">SimpleTest</a>...
+ <table>
+<thead>
+ <tr>
+<th>Attente</th>
+<th>Nécessite <span class="new_code">tally()</span>
+</th>
+</tr>
+ </thead>
+<tbody>
+<tr>
+ <td><span class="new_code">expectArguments($method, $args)</span></td>
+ <td style="text-align: center">Non</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectArgumentsAt($timing, $method, $args)</span></td>
+ <td style="text-align: center">Non</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectCallCount($method, $count)</span></td>
+ <td style="text-align: center">Oui</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectMaximumCallCount($method, $count)</span></td>
+ <td style="text-align: center">Non</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectMinimumCallCount($method, $count)</span></td>
+ <td style="text-align: center">Oui</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectNever($method)</span></td>
+ <td style="text-align: center">Non</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectOnce($method, $args)</span></td>
+ <td style="text-align: center">Oui</td>
+ </tr>
+ <tr>
+ <td><span class="new_code">expectAtLeastOnce($method, $args)</span></td>
+ <td style="text-align: center">Oui</td>
+ </tr>
+ </tbody>
+</table>
+ Où les paramètres sont...
+ <dl>
+ <dt class="new_code">$method</dt>
+ <dd>Le nom de la méthode, sous la forme d'une chaîne,
+ à laquelle la condition doit être appliquée.</dd>
+ <dt class="new_code">$args</dt>
+ <dd>
+ Les arguments sous la forme d'une liste.
+ Les jokers peuvent être inclus de la même manière
+ qu'avec <span class="new_code">setReturn()</span>.
+ Cet argument est optionnel pour <span class="new_code">expectOnce()</span>
+ et <span class="new_code">expectAtLeastOnce()</span>.
+ </dd>
+ <dt class="new_code">$timing</dt>
+ <dd>
+ Le seul point dans le temps pour tester
+ la condition. Le premier appel commence à zéro.
+ </dd>
+ <dt class="new_code">$count</dt>
+ <dd>Le nombre d'appels attendu.</dd>
+ </dl>
+ La méthode <span class="new_code">expectMaximumCallCount()</span>
+ est légèrement différente dans le sens où elle ne pourra
+ générer qu'un échec. Elle reste silencieuse
+ si la limite n'est jamais atteinte.
+ </p>
+ <p>
+ Par ailleurs si vous avez just un appel dans votre test,
+ vérifiez bien que vous utiliser
+ <span class="new_code">expectOnce</span>.<br>
+ Utiliser <span class="new_code">$mocked-&gt;expectAt(0, 'method', 'args);</span>
+ tout seul ne sera pas pris en compte :
+ la vérification des arguments et le comptage total
+ sont pour l'instant encore indépendant.
+ </p>
+ <p>
+ Comme avec les assertions dans les scénarios de test,
+ toutes ces attentes peuvent accepter une surcharge de
+ message sous la forme d'un paramètre supplémentaire.
+ Par ailleurs le message d'échec original peut être inclus
+ dans le résultat avec "%s".
+ </p>
+
+ <p><a class="target" name="approches"><h2>D'autres approches</h2></a></p>
+ <p>
+ Il existe trois approches pour créer des objets
+ fantaisie en comprenant celle utilisée par SimpleTest.
+ Les coder à la main en utilisant une classe de base,
+ les générer dans un fichier ou les générer dynamiquement à la volée.
+ </p>
+ <p>
+ Les objets fantaisie générés avec
+ <a href="simple_test.html">SimpleTest</a> sont dynamiques.
+ Ils sont créés à l'exécution dans la mémoire,
+ grâce à <span class="new_code">eval()</span>, plutôt qu'écrits dans un fichier.
+ Cette opération les rend facile à créer,
+ en une seule ligne, surtout par rapport à leur création
+ à la main dans une hiérarchie de classe parallèle.
+ Le problème avec ce comportement tient généralement
+ dans la mise en place des tests proprement dits.
+ Si les objets originaux changent les versions fantaisie
+ sur lesquels reposent les tests, une désynchronisation peut subvenir.
+ Cela peut aussi arriver avec l'approche en hiérarchie parallèle,
+ mais c'est détecté beaucoup plus vite.
+ </p>
+ <p>
+ Bien sûr, la solution est d'ajouter de véritables tests d'intégration.
+ Vous n'en avez pas besoin de beaucoup
+ et le côté pratique des objets fantaisie fait plus
+ que compenser la petite dose de test supplémentaire.
+ Vous ne pouvez pas avoir confiance dans du code qui
+ ne serait testé que par des objets fantaisie.
+ </p>
+ <p>
+ Si vous restez déterminé de construire des librairies
+ statiques d'objets fantaisie parce que vous souhaitez
+ émuler un comportement très spécifique,
+ vous pouvez y parvenir grâce au générateur de classe de SimpleTest.
+ Dans votre fichier librairie, par exemple
+ <em>mocks/connection.php</em> pour une connexion à une base de données,
+ créer un objet fantaisie et provoquer l'héritage
+ pour hériter pour surcharger des méthodes spéciales
+ ou ajouter des préréglages...
+<pre>
+&lt;?php
+ require_once('simpletest/mock_objects.php');
+ require_once('../classes/connection.php');
+<strong>
+ Mock::generate('Connection', 'BasicMockConnection');
+ class MockConnection extends BasicMockConnection {
+ function MockConnection(&amp;$test, $wildcard = '*') {
+ $this-&gt;BasicMockConnection($test, $wildcard);
+ $this-&gt;setReturn('query', false);
+ }
+ }</strong>
+?&gt;
+</pre>
+ L'appel <span class="new_code">generate</span> dit au générateur de classe
+ d'en créer une appelée <span class="new_code">BasicMockConnection</span>
+ plutôt que la plus courante <span class="new_code">MockConnection</span>.
+ Ensuite nous héritons à partir de celle-ci pour obtenir
+ notre version de <span class="new_code">MockConnection</span>.
+ En interceptant de cette manière nous pouvons ajouter
+ un comportement, ici transformer la valeur par défaut de
+ <span class="new_code">query()</span> en "false".
+ En utilisant le nom par défaut nous garantissons
+ que le générateur de classe fantaisie n'en recréera
+ pas une autre différente si il est invoqué ailleurs
+ dans les tests. Il ne créera jamais de classe
+ si elle existe déjà. Aussi longtemps que le fichier
+ ci-dessus est inclus avant alors tous les tests qui
+ généraient <span class="new_code">MockConnection</span> devraient
+ utiliser notre version à présent. Par contre si
+ nous avons une erreur dans l'ordre et que la librairie
+ de fantaisie en crée une d'abord alors la création
+ de la classe échouera tout simplement.
+ </p>
+ <p>
+ Utiliser cette astuce si vous vous trouvez avec beaucoup
+ de comportement en commun sur les objets fantaisie
+ ou si vous avez de fréquents problèmes d'intégration
+ plus tard dans les étapes de test.
+ </p>
+
+ <p><a class="target" name="autres_testeurs"><h2>Je pense que SimpleTest pue !</h2></a></p>
+ <p>
+ Mais au moment d'écrire ces lignes c'est le seul
+ à gérer les objets fantaisie, donc vous êtes bloqué avec lui ?
+ </p>
+ <p>
+ Non, pas du tout.
+ <a href="simple_test.html">SimpleTest</a> est une boîte à outils
+ et parmi ceux-ci on trouve les objets fantaisie
+ qui peuvent être utilisés indépendamment.
+ Supposons que vous avez votre propre testeur unitaire favori
+ et que tous vos tests actuels l'utilisent.
+ Prétendez que vous avez appelé votre tester unitaire PHPUnit
+ (c'est ce que tout le monde a fait) et que la classe principale
+ de test ressemble à...
+<pre>
+class PHPUnit {
+ function PHPUnit() {
+ }
+
+ function assertion($message, $assertion) {
+ }
+ ...
+}
+</pre>
+ La seule chose que la méthode <span class="new_code">assertion()</span> réalise,
+ c'est de préparer une sortie embellie alors le paramètre boolien
+ de l'assertion sert à déterminer s'il s'agit d'une erreur ou d'un succès.
+ Supposons qu'elle est utilisée de la manière suivante...
+<pre>
+$unit_test = new PHPUnit();
+$unit_test&gt;assertion('I hope this file exists', file_exists('my_file'));
+</pre>
+ Comment utiliser les objets fantaisie avec ceci ?
+ </p>
+ <p>
+ Il y a une méthode protégée sur la classe de base
+ des objets fantaisie : elle s'appelle <span class="new_code">_assertTrue()</span>.
+ En surchargeant cette méthode nous pouvons utiliser
+ notre propre format d'assertion.
+ Nous commençons avec une sous-classe, dans <em>my_mock.php</em>...
+<pre>
+<strong>&lt;?php
+ require_once('simpletest/mock_objects.php');
+
+ class MyMock extends SimpleMock() {
+ function MyMock(&amp;$test, $wildcard) {
+ $this-&gt;SimpleMock($test, $wildcard);
+ }
+
+ function _assertTrue($assertion, $message) {
+ $test = &amp;$this-&gt;getTest();
+ $test-&gt;assertion($message, $assertion);
+ }
+ }
+?&gt;</strong>
+</pre>
+ Maintenant une instance de <span class="new_code">MyMock</span>
+ créera un objet qui parle le même langage que votre testeur.
+ Bien sûr le truc c'est que nous créons jamais un tel objet :
+ le générateur s'en chargera. Nous avons juste besoin
+ d'une ligne de code supplémentaire pour dire au générateur
+ d'utiliser vos nouveaux objets fantaisie...
+<pre>
+&lt;?php
+ require_once('simpletst/mock_objects.php');
+
+ class MyMock extends SimpleMock() {
+ function MyMock($test, $wildcard) {
+ $this-&gt;SimpleMock(&amp;$test, $wildcard);
+ }
+
+ function _assertTrue($assertion, $message , &amp;$test) {
+ $test-&gt;assertion($message, $assertion);
+ }
+ }<strong>
+ SimpleTestOptions::setMockBaseClass('MyMock');</strong>
+?&gt;
+</pre>
+ A partir de maintenant vous avez juste à inclure
+ <em>my_mock.php</em> à la place de la version par défaut
+ <em>simple_mock.php</em> et vous pouvez introduire
+ des objets fantaisie dans votre suite de tests existants.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ L'article originel sur
+ <a href="http://www.mockobjects.com/">les objets fantaisie</a>.
+ </li>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page d'accueil de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/overview.html b/vendors/simpletest/docs/fr/overview.html
new file mode 100644
index 000000000..3225b969a
--- /dev/null
+++ b/vendors/simpletest/docs/fr/overview.html
@@ -0,0 +1,318 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>
+ Aperçu et liste des fonctionnalités des testeurs unitaires PHP et web de SimpleTest PHP
+ </title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Apercu de SimpleTest</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#resume">Résumé rapide</a> de l'outil SimpleTest pour PHP.
+ </li>
+<li>
+ <a href="#fonctionnalites">La liste des fonctionnalites</a>, à la fois présentes et à venir.
+ </li>
+<li>
+ Il y a beaucoup de <a href="#ressources">ressources sur les tests unitaires</a> sur le web.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="resume"><h2>Qu'est-ce que SimpleTest ?</h2></a></p>
+ <p>
+ Le coeur de SimpleTest est un framework de test construit autour de classes de scénarios de test. Celles-ci sont écrites comme des extensions des classes premières de scénarios de test, chacune élargie avec des méthodes qui contiennent le code de test effectif. Les scripts de test de haut niveau invoque la méthode <span class="new_code">run()</span> à chaque scénario de test successivement. Chaque méthode de test est écrite pour appeler des assertions diverses que le développeur suppose être vraies, <span class="new_code">assertEqual()</span> par exemple. Si l'assertion est correcte, alors un succès est expédié au rapporteur observant le test, mais toute erreur déclenche une alerte et une description de la dissension.
+ </p>
+ <p>
+ Un <a href="unit_test_documentation.html">scénario de test</a> ressemble à...
+<pre>
+class <strong>MyTestCase</strong> extends UnitTestCase {
+ <strong>
+ function testLog() {
+ $log = &amp;new Log('my.log');
+ $log-&gt;message('Hello');
+ $this-&gt;assertTrue(file_exists('my.log'));
+ }</strong>
+}
+</pre>
+ </p>
+ <p>
+ Ces outils sont conçus pour le développeur. Les tests sont écrits en PHP directement, plus ou moins simultanément avec la construction de l'application elle-même. L'avantage d'utiliser PHP lui-même comme langage de test est qu'il n'y a pas de nouveau langage à apprendre, les tests peuvent commencer directement et le développeur peut tester n'importe quelle partie du code. Plus simplement, toutes les parties qui peuvent être accédées par le code de l'application peuvent aussi être accédées par le code de test si ils sont tous les deux dans le même langage.
+ </p>
+ <p>
+ Le type de scénario de test le plus simple est le <span class="new_code">UnitTestCase</span>. Cette classe de scénario de test inclut les tests standards pour l'égalité, les références et l'appariement de motifs (via les expressions rationnelles). Ceux-ci testent ce que vous seriez en droit d'attendre du résultat d'une fonction ou d'une méthode. Il s'agit du type de test le plus commun pendant le quotidien du développeur, peut-être 95% des scénarios de test.
+ </p>
+ <p>
+ La tâche ultime d'une application web n'est cependant pas de produire une sortie correcte à partir de méthodes ou d'objets, mais plutôt de produire des pages web. La classe <span class="new_code">WebTestCase</span> teste des pages web. Elle simule un navigateur web demandant une page, de façon exhaustive : cookies, proxies, connexions sécurisées, authentification, formulaires, cadres et la plupart des éléments de navigation. Avec ce type de scénario de test, le développeur peut garantir que telle ou telle information est présente dans la page et que les formulaires ainsi que les sessions sont gérés comme il faut.
+ </p>
+ <p>
+ Un <a href="web_tester_documentation.html">scénario de test web</a> ressemble à...
+<pre>
+class <strong>MySiteTest</strong> extends WebTestCase {
+ <strong>
+ function testHomePage() {
+ $this-&gt;get('http://www.my-site.com/index.php');
+ $this-&gt;assertTitle('My Home Page');
+ $this-&gt;clickLink('Contact');
+ $this-&gt;assertTitle('Contact me');
+ $this-&gt;assertWantedPattern('/Email me at/');
+ }</strong>
+}
+</pre>
+ </p>
+
+ <p><a class="target" name="fonctionnalites"><h2>Liste des fonctionnalites</h2></a></p>
+ <p>
+ Ci-dessous vous trouverez un canevas assez brut des fonctionnalités à aujourd'hui et pour demain, sans oublier leur date approximative de publication. J'ai bien peur qu'il soit modifiable sans pré-avis étant donné que les jalons dépendent beaucoup sur le temps disponible. Les trucs en vert ont été codés, mais pas forcément déjà rendus public. Si vous avez une besoin pressant pour une fonctionnalité verte mais pas encore publique alors vous devriez retirer le code directement sur le CVS chez SourceFourge. Une fonctionnalitée publiée est indiqué par "Fini".
+ <table>
+<thead>
+ <tr>
+<th>Fonctionnalité</th>
+<th>Description</th>
+<th>Publication</th>
+</tr>
+ </thead>
+<tbody>
+<tr>
+ <td>Scénariot de test unitaire</td>
+ <td>Les classes de test et assertions de base</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Affichage HTML</td>
+ <td>L'affichage le plus simple possible</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Autochargement des scénarios de test</td>
+ <td>Lire un fichier avec des scénarios de test et les charger dans un groupe de tests automatiquement</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Générateur de code d'objets fantaisie</td>
+ <td>Des objets capable de simuler d'autres objets, supprimant les dépendances dans les tests</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Bouchons serveur</td>
+ <td>Des objets fantaisie sans résultat attendu à utiliser à l'extérieur des scénarios de test, pour le prototypage par exemple.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Intégration d'autres testeurs unitaires</td>
+ <td>
+ La capacité de lire et simuler d'autres scénarios de test en provenance de PHPUnit et de PEAR::Phpunit.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Scénario de test web</td>
+ <td>Appariement basique de motifs dans une page téléchargée.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Analyse de page HTML</td>
+ <td>Permet de suivre les liens et de trouver la balise de titre</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Simulacre partiel</td>
+ <td>Simuler des parties d'une classe pour tester moins qu'une classe ou dans des cas complexes.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Gestion des cookies Web</td>
+ <td>Gestion correcte des cookies au téléchargement d'une page.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Suivi des redirections</td>
+ <td>Le téléchargement d'une page suit automatiquement une redirection 300.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Analyse d'un formulaire</td>
+ <td>La capacité de valider un formulaire simple et d'en lire les valeurs par défaut.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Interface en ligne de commande</td>
+ <td>Affiche le résultat des tests sans navigateur web.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Mise à nu des attentes d'une classe</td>
+ <td>Peut créer des tests précis avec des simulacres ainsi que des scénarios de test.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Sortie et analyse XML</td>
+ <td>Permet de tester sur plusieurs hôtes et d'intégrer des extensions d'acceptation de test.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Scénario de test en ligne de commande</td>
+ <td>Permet de tester des outils ou scripts en ligne de commande et de manier des fichiers.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Compatibilité avec PHP Documentor</td>
+ <td>Génération automatique et complète de la documentation au niveau des classes.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Interface navigateur</td>
+ <td>Mise à nu des niveaux bas de l'interface du navigateur web pour des scénarios de test plus précis.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Authentification HTTP</td>
+ <td>Téléchargement des pages web protégées avec une authentification basique seulement.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Boutons de navigation d'un navigateur</td>
+ <td>Arrière, avant et recommencer</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Support de SSL</td>
+ <td>Peut se connecter à des pages de type https.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Support de proxy</td>
+ <td>Peut se connecter via des proxys communs</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Support des cadres</td>
+ <td>Gère les cadres dans les scénarios de test web.</td>
+ <td style="color: green;">Fini</td>
+ </tr>
+ <tr>
+ <td>Test de l'upload de fichier</td>
+ <td>Peut simuler la balise input de type file</td>
+ <td style="color: red;">1.0.1</td>
+ </tr>
+ <tr>
+ <td>Amélioration sur la machinerie des rapports</td>
+ <td>Retouche sur la transmission des messages pour une meilleur coopération avec les IDEs</td>
+ <td style="color: red;">1.1</td>
+ </tr>
+ <tr>
+ <td>Amélioration de l'affichage des tests</td>
+ <td>Une meilleure interface graphique web, avec un arbre des scénarios de test.</td>
+ <td style="color: red;">1.1</td>
+ </tr>
+ <tr>
+ <td>Localisation</td>
+ <td>Abstraction des messages et génration du code à partir de fichiers XML.</td>
+ <td style="color: red;">1.1</td>
+ </tr>
+ <tr>
+ <td>Simulation d'interface</td>
+ <td>Peut générer des objets fantaisie tant vers des interfaces que vers des classes.</td>
+ <td style="color: red;">2.0</td>
+ </tr>
+ <tr>
+ <td>Test sur es exceptions</td>
+ <td>Dans le même esprit que sur les tests des erreurs PHP.</td>
+ <td style="color: red;">2.0</td>
+ </tr>
+ <tr>
+ <td>Rercherche d'éléments avec XPath</td>
+ <td>Peut utiliser Tidy HTML pour un appariement plus rapide et plus souple.</td>
+ <td style="color: red;">2.0</td>
+ </tr>
+ </tbody>
+</table>
+ La migration vers PHP5 commencera juste après la série des 1.0, à partir de là PHP4 ne sera plus supporté. SimpleTest est actuellement compatible avec PHP5 mais n'utilisera aucune des nouvelles fonctionnalités avant la version 2.
+ </p>
+
+ <p><a class="target" name="ressources"><h2>Ressources sur le web pour les tests</h2></a></p>
+ <p>
+ Le processus est au moins aussi important que les outils. Le type de procédure que fait un usage le plus intensif des outils de test pour développeur est bien sûr l'<a href="http://www.extremeprogramming.org/">Extreme Programming</a>. Il s'agit là d'une des <a href="http://www.agilealliance.com/articles/index">méthodes agiles</a> qui combinent plusieurs pratiques pour "lisser la courbe de coût" du développement logiciel. La plus extrème reste le <a href="http://www.testdriven.com/modules/news/">développement piloté par les tests</a>, où vous devez adhérer à la règle du <cite>pas de code avant d'avoir un test</cite>. Si vous êtes plutôt du genre planninficateur ou que vous estimez que l'expérience compte plus que l'évolution, vous préférerez peut-être l'approche <a href="http://www.therationaledge.com/content/dec_01/f_spiritOfTheRUP_pk.html">RUP</a>. Je ne l'ai pas testé mais je peux voir où vous aurez besoin d'outils de test (cf. illustration 9).
+ </p>
+ <p>
+ La plupart des testeurs unitaires sont dans une certaine mesure un clone de <a href="http://www.junit.org/">JUnit</a>, au moins dans l'interface. Il y a énormément d'information sur le site de JUnit, à commencer par la <a href="http://junit.sourceforge.net/doc/faq/faq.htm">FAQ</a> quie contient pas mal de conseils généraux sur les tests. Une fois mordu par le bogue vous apprécierez sûrement la phrase <a href="http://junit.sourceforge.net/doc/testinfected/testing.htm">infecté par les tests</a> trouvée par Eric Gamma. Si vous êtes encore en train de tergiverser sur un testeur unitaire, sachez que les choix principaux sont <a href="http://phpunit.sourceforge.net/">PHPUnit</a> et <a href="http://pear.php.net/manual/en/package.php.phpunit.php">Pear PHP::PHPUnit</a>. De nombreuses fonctionnalités de SimpleTest leurs font défaut, mais la version PEAR a d'ores et déjà été mise à jour pour PHP5. Elle est aussi recommandée si vous portez des scénarios de test existant depuis <a href="http://www.junit.org/">JUnit</a>.
+ </p>
+ <p>
+ Les développeurs de bibliothèque n'ont pas l'air de livrer très souvent des tests avec leur code : c'est bien dommage. Le code d'une bibliothèque qui inclut des tests peut être remanié avec plus de sécurité et le code de test sert de documentation additionnelle dans un format assez standard. Ceci peut épargner la pêche aux indices dans le code source lorsque qu'un problème survient, en particulier lors de la mise à jour d'une telle bibliothèque. Parmi les bibliothèques utilisant SimpleTest comme testeur unitaire on retrouve <a href="http://wact.sourceforge.net/">WACT</a> et <a href="http://sourceforge.net/projects/htmlsax">PEAR::XML_HTMLSax</a>.
+ </p>
+ <p>
+ Au jour d'aujourd'hui il manque tristement beaucoup de matière sur les objets fantaisie : dommage, surtout que tester unitairement sans eux représente pas mal de travail en plus. L'<a href="http://www.sidewize.com/company/mockobjects.pdf">article original sur les objets fantaisie</a> est très orienté Java, mais reste intéressant à lire. Etant donné qu'il s'agit d'une nouvelle technologie il y a beaucoup de discussions et de débats sur comment les utiliser, souvent sur des wikis comme <a href="http://xpdeveloper.com/cgi-bin/oldwiki.cgi?MockObjects">Extreme Tuesday</a> ou <a href="http://www.mockobjects.com/MocksObjectsPaper.html">www.mockobjects.com</a>ou <a href="http://c2.com/cgi/wiki?MockObject">the original C2 Wiki</a>. Injecter des objets fantaisie dans une classe est un des champs principaux du débat : cet <a href="http://www-106.ibm.com/developerworks/java/library/j-mocktest.html">article chez IBM</a> en est un bon point de départ.
+ </p>
+ <p>
+ Il y a énormement d'outils de test web mais la plupart sont écrits en Java. De plus les tutoriels et autres conseils sont plutôt rares. Votre seul espoir est de regarder directement la documentation pour <a href="http://httpunit.sourceforge.net/">HTTPUnit</a>, <a href="http://htmlunit.sourceforge.net/">HTMLUnit</a> ou <a href="http://jwebunit.sourceforge.net/">JWebUnit</a> et d'espérer y trouver pour des indices. Il y a aussi des frameworks basés sur XML, mais de nouveau la plupart ont besoin de Java pour tourner.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ <a href="unit_test_documentation.html">Documentation pour SimpleTest</a>.
+ </li>
+<li>
+ <a href="http://www.lastcraft.com/first_test_tutorial.php">Comment écrire des scénarios de test en PHP</a> est un tutoriel plutôt avancé.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API de SimpleTest</a> par phpdoc.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/partial_mocks_documentation.html b/vendors/simpletest/docs/fr/partial_mocks_documentation.html
new file mode 100644
index 000000000..32a39c760
--- /dev/null
+++ b/vendors/simpletest/docs/fr/partial_mocks_documentation.html
@@ -0,0 +1,460 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : les objets fantaisie partiels</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur les objets fantaisie partiels</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#injection">Le problème de l'injection d'un objet fantaisie</a>.
+ </li>
+<li>
+ Déplacer la création vers une méthode <a href="#creation">fabrique protégée</a>.
+ </li>
+<li>
+ <a href="#partiel">L'objet fantaisie partiel</a> génère une sous-classe.
+ </li>
+<li>
+ Les objets fantaisie partiels <a href="#moins">testent moins qu'une classe</a>.
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ Un objet fantaisie partiel n'est ni plus ni moins
+ qu'un modèle de conception pour soulager un problème spécifique
+ du test avec des objets fantaisie, celui de placer
+ des objets fantaisie dans des coins serrés.
+ Il s'agit d'un outil assez limité et peut-être même
+ une idée pas si bonne que ça. Elle est incluse dans SimpleTest
+ pour la simple raison que je l'ai trouvée utile
+ à plus d'une occasion et qu'elle m'a épargnée
+ pas mal de travail dans ces moments-là.
+ </p>
+
+ <p><a class="target" name="injection"><h2>Le problème de l'injection dans un objet fantaisie</h2></a></p>
+ <p>
+ Quand un objet en utilise un autre il est très simple
+ d'y faire circuler une version fantaisie déjà prête
+ avec ses attentes. Les choses deviennent un peu plus délicates
+ si un objet en crée un autre et que le créateur est celui
+ que l'on souhaite tester. Cela revient à dire que l'objet
+ créé devrait être une fantaisie, mais nous pouvons
+ difficilement dire à notre classe sous test de créer
+ un objet fantaisie plutôt qu'un "vrai" objet.
+ La classe testée ne sait même pas qu'elle travaille dans un environnement de test.
+ </p>
+ <p>
+ Par exemple, supposons que nous sommes en train
+ de construire un client telnet et qu'il a besoin
+ de créer une socket réseau pour envoyer ses messages.
+ La méthode de connexion pourrait ressemble à quelque chose comme...
+<pre>
+<strong>&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...
+ function &amp;connect($ip, $port, $username, $password) {
+ $socket = &amp;new Socket($ip, $port);
+ $socket-&gt;read( ... );
+ ...
+ }
+}
+?&gt;</strong>
+</pre>
+ Nous voudrions vraiment avoir une version fantaisie
+ de l'objet socket, que pouvons nous faire ?
+ </p>
+ <p>
+ La première solution est de passer la socket en
+ tant que paramètre, ce qui force la création
+ au niveau inférieur. Charger le client de cette tâche
+ est effectivement une bonne approche si c'est possible
+ et devrait conduire à un remaniement -- de la création
+ à partir de l'action. En fait, c'est là une des manières
+ avec lesquels tester en s'appuyant sur des objets fantaisie
+ vous force à coder des solutions plus resserrées sur leur objectif.
+ Ils améliorent votre programmation.
+ </p>
+ <p>
+ Voici ce que ça devrait être...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...
+ <strong>function &amp;connect(&amp;$socket, $username, $password) {
+ $socket-&gt;read( ... );
+ ...
+ }</strong>
+}
+?&gt;
+</pre>
+ Sous-entendu, votre code de test est typique d'un cas
+ de test avec un objet fantaisie.
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new Telnet();
+ $telnet-&gt;connect($socket, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ C'est assez évident que vous ne pouvez descendre que d'un niveau.
+ Vous ne voudriez pas que votre application de haut niveau
+ crée tous les fichiers de bas niveau, sockets et autres connexions
+ à la base de données dont elle aurait besoin.
+ Elle ne connaîtrait pas les paramètres du constructeur de toute façon.
+ </p>
+ <p>
+ La solution suivante est de passer l'objet créé sous la forme
+ d'un paramètre optionnel...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...<strong>
+ function &amp;connect($ip, $port, $username, $password, $socket = false) {
+ if (!$socket) {
+ $socket = &amp;new Socket($ip, $port);
+ }
+ $socket-&gt;read( ... );</strong>
+ ...
+ return $socket;
+ }
+}
+?&gt;
+</pre>
+ Pour une solution rapide, c'est généralement suffisant.
+ Ensuite le test est très similaire : comme si le paramètre
+ était transmis formellement...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new Telnet();
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret', &amp;$socket);
+ ...</strong>
+ }
+}
+</pre>
+ Le problème de cette approche tient dans son manque de netteté.
+ Il y a du code de test dans la classe principale et aussi
+ des paramètres transmis dans le scénario de test
+ qui ne sont jamais utilisés. Il s'agit là d'une approche
+ rapide et sale, mais qui ne reste pas moins efficace
+ dans la plupart des situations.
+ </p>
+ <p>
+ Une autre solution encore est de laisser un objet fabrique
+ s'occuper de la création...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {<strong>
+ function Telnet(&amp;$network) {
+ $this-&gt;_network = &amp;$network;
+ }</strong>
+ ...
+ function &amp;connect($ip, $port, $username, $password) {<strong>
+ $socket = &amp;$this-&gt;_network-&gt;createSocket($ip, $port);
+ $socket-&gt;read( ... );</strong>
+ ...
+ return $socket;
+ }
+}
+?&gt;
+</pre>
+ Il s'agit là probablement de la réponse la plus travaillée
+ étant donné que la création est maintenant située
+ dans une petite classe spécialisée. La fabrique réseau
+ peut être testée séparément et utilisée en tant que fantaisie
+ quand nous testons la classe telnet...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $network = &amp;new MockNetwork($this);
+ $network-&gt;setReturnReference('createSocket', $socket);
+ $telnet = &amp;new Telnet($network);
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ Le problème reste que nous ajoutons beaucoup de classes
+ à la bibliothèque. Et aussi que nous utilisons beaucoup
+ de fabriques ce qui rend notre code un peu moins intuitif.
+ La solution la plus flexible, mais aussi la plus complexe.
+ </p>
+ <p>
+ Peut-on trouver un juste milieu ?
+ </p>
+
+ <p><a class="target" name="creation"><h2>Méthode fabrique protégée</h2></a></p>
+ <p>
+ Il existe une technique pour palier à ce problème
+ sans créer de nouvelle classe dans l'application;
+ par contre elle induit la création d'une sous-classe au moment du test.
+ Premièrement nous déplaçons la création de la socket dans sa propre méthode...
+<pre>
+&lt;?php
+require_once('socket.php');
+
+class Telnet {
+ ...
+ function &amp;connect($ip, $port, $username, $password) {<strong>
+ $socket = &amp;$this-&gt;_createSocket($ip, $port);</strong>
+ $socket-&gt;read( ... );
+ ...
+ }<strong>
+
+ function &amp;_createSocket($ip, $port) {
+ return new Socket($ip, $port);
+ }</strong>
+}
+?&gt;
+</pre>
+ Il s'agit là de la seule modification dans le code de l'application.
+ </p>
+ <p>
+ Pour le scénario de test, nous devons créer
+ une sous-classe de manière à intercepter la création de la socket...
+<pre>
+<strong>class TelnetTestVersion extends Telnet {
+ var $_mock;
+
+ function TelnetTestVersion(&amp;$mock) {
+ $this-&gt;_mock = &amp;$mock;
+ $this-&gt;Telnet();
+ }
+
+ function &amp;_createSocket() {
+ return $this-&gt;_mock;
+ }
+}</strong>
+</pre>
+ Ici j'ai déplacé la fantaisie dans le constructeur,
+ mais un setter aurait fonctionné tout aussi bien.
+ Notez bien que la fantaisie est placée dans une variable
+ d'objet avant que le constructeur ne soit attaché.
+ C'est nécessaire dans le cas où le constructeur appelle
+ <span class="new_code">connect()</span>.
+ Autrement il pourrait donner un valeur nulle à partir de
+ <span class="new_code">_createSocket()</span>.
+ </p>
+ <p>
+ Après la réalisation de tout ce travail supplémentaire
+ le scénario de test est assez simple.
+ Nous avons juste besoin de tester notre nouvelle classe à la place...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new TelnetTestVersion($socket);
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ Cette nouvelle classe est très simple bien sûr.
+ Elle ne fait qu'initier une valeur renvoyée, à la manière
+ d'une fantaisie. Ce serait pas mal non plus si elle pouvait
+ vérifier les paramètres entrants.
+ Exactement comme un objet fantaisie.
+ Il se pourrait bien que nous ayons à réaliser cette astuce régulièrement :
+ serait-il possible d'automatiser la création de cette sous-classe ?
+ </p>
+
+ <p><a class="target" name="partiel"><h2>Un objet fantaisie partiel</h2></a></p>
+ <p>
+ Bien sûr la réponse est "oui"
+ ou alors j'aurais arrêté d'écrire depuis quelques temps déjà !
+ Le test précédent a représenté beaucoup de travail,
+ mais nous pouvons générer la sous-classe en utilisant
+ une approche à celle des objets fantaisie.
+ </p>
+ <p>
+ Voici donc une version avec objet fantaisie partiel du test...
+<pre>
+<strong>Mock::generatePartial(
+ 'Telnet',
+ 'TelnetTestVersion',
+ array('_createSocket'));</strong>
+
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {<strong>
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new TelnetTestVersion($this);
+ $telnet-&gt;setReturnReference('_createSocket', $socket);
+ $telnet-&gt;Telnet();
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...</strong>
+ }
+}
+</pre>
+ La fantaisie partielle est une sous-classe de l'original
+ dont on aurait "remplacé" les méthodes sélectionnées
+ avec des versions de test. L'appel à <span class="new_code">generatePartial()</span>
+ nécessite trois paramètres : la classe à sous classer,
+ le nom de la nouvelle classe et une liste des méthodes à simuler.
+ </p>
+ <p>
+ Instancier les objets qui en résultent est plutôt délicat.
+ L'unique paramètre du constructeur d'un objet fantaisie partiel
+ est la référence du testeur unitaire.
+ Comme avec les objets fantaisie classiques c'est nécessaire
+ pour l'envoi des résultats de test en réponse à la vérification des attentes.
+ </p>
+ <p>
+ Une nouvelle fois le constructeur original n'est pas lancé.
+ Indispensable dans le cas où le constructeur aurait besoin
+ des méthodes fantaisie : elles n'ont pas encore été initiées !
+ Nous initions les valeurs retournées à cet instant et
+ ensuite lançons le constructeur avec ses paramètres normaux.
+ Cette construction en trois étapes de "new",
+ suivie par la mise en place des méthodes et ensuite
+ par la lancement du constructeur proprement dit est
+ ce qui distingue le code d'un objet fantaisie partiel.
+ </p>
+ <p>
+ A part pour leur construction, toutes ces méthodes
+ fantaisie ont les mêmes fonctionnalités que dans
+ le cas des objets fantaisie et toutes les méthodes
+ non fantaisie se comportent comme avant.
+ Nous pouvons mettre en place des attentes très facilement...
+<pre>
+class TelnetTest extends UnitTestCase {
+ ...
+ function testConnection() {
+ $socket = &amp;new MockSocket($this);
+ ...
+ $telnet = &amp;new TelnetTestVersion($this);
+ $telnet-&gt;setReturnReference('_createSocket', $socket);<strong>
+ $telnet-&gt;expectOnce('_createSocket', array('127.0.0.1', 21));</strong>
+ $telnet-&gt;Telnet();
+ $telnet-&gt;connect('127.0.0.1', 21, 'Me', 'Secret');
+ ...<strong>
+ $telnet-&gt;tally();</strong>
+ }
+}
+</pre>
+ </p>
+
+ <p><a class="target" name="moins"><h2>Tester moins qu'une classe</h2></a></p>
+ <p>
+ Les méthodes issues d'un objet fantaisie n'ont pas
+ besoin d'être des méthodes fabrique, Il peut s'agir
+ de n'importe quelle sorte de méthode.
+ Ainsi les objets fantaisie partiels nous permettent
+ de prendre le contrôle de n'importe quelle partie d'une classe,
+ le constructeur excepté. Nous pourrions même aller jusqu'à
+ créer des fantaisies sur toutes les méthodes à part celle
+ que nous voulons effectivement tester.
+ </p>
+ <p>
+ Cette situation est assez hypothétique, étant donné
+ que je ne l'ai jamais essayée. Je suis ouvert à cette possibilité,
+ mais je crains qu'en forçant la granularité d'un objet
+ on n'obtienne pas forcément un code de meilleur qualité.
+ Personnellement j'utilise les objets fantaisie partiels
+ comme moyen de passer outre la création ou alors
+ de temps en temps pour tester le modèle de conception TemplateMethod.
+ </p>
+ <p>
+ Pour choisir le mécanisme à utiliser, on en revient
+ toujours aux standards de code de votre projet.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API complète pour SimpleTest</a>
+ à partir de PHPDoc.
+ </li>
+<li>
+ La méthode fabrique protégée est décrite dans
+ <a href="http://www-106.ibm.com/developerworks/java/library/j-mocktest.html">
+ cet article d'IBM</a>. Il s'agit de l'unique papier
+ formel que j'ai vu sur ce problème.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/reporter_documentation.html b/vendors/simpletest/docs/fr/reporter_documentation.html
new file mode 100644
index 000000000..0dc56edcf
--- /dev/null
+++ b/vendors/simpletest/docs/fr/reporter_documentation.html
@@ -0,0 +1,534 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : le rapporteur de test</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur le rapporteur de test</h1>
+ This page...
+ <ul>
+<li>
+ Afficher <a href="#html">les résultats en HTML</a>
+ </li>
+<li>
+ Afficher et <a href="#autres">rapporter les résultats</a>
+ dans d'autres formats
+ </li>
+<li>
+ Utilisé <a href="#cli">SimpleTest depuis la ligne de commande</a>
+ </li>
+<li>
+ <a href="#xml">Utiliser XML</a> pour des tests distants
+ </li>
+</ul>
+<div class="content">
+
+ <p>
+ SimpleTest suit plutôt plus que moins le modèle MVC (Modèle-Vue-Contrôleur).
+ Les classes "reporter" sont les vues et les modèles
+ sont vos scénarios de test et leur hiérarchie.
+ Le contrôleur est le plus souvent masqué à l'utilisateur
+ de SimpleTest à moins de vouloir changer la façon
+ dont les tests sont effectivement exécutés,
+ auquel cas il est possible de surcharger les objets
+ "runner" (ceux de l'exécuteur) depuis l'intérieur
+ d'un scénario de test. Comme d'habitude avec MVC,
+ le contrôleur est plutôt indéfini et il existe d'autres endroits
+ pour contrôler l'exécution des tests.
+ </p>
+
+ <p><a class="target" name="html"><h2>Les résultats rapportés au format HTML</h2></a></p>
+ <p>
+ L'affichage par défaut est minimal à l'extrême.
+ Il renvoie le succès ou l'échec avec les barres conventionnelles
+ - rouge et verte - et affichent une trace d'arborescence
+ des groupes de test pour chaque assertion erronée. Voici un tel échec...
+ <div class="demo">
+ <h1>File test</h1>
+ <span class="fail">Fail</span>: createnewfile-&gt;True assertion failed.<br>
+ <div style="padding: 8px; margin-top: 1em; background-color: red; color: white;">1/1 test cases complete.
+ <strong>0</strong> passes, <strong>1</strong> fails and <strong>0</strong> exceptions.</div>
+ </div>
+ Alors qu'ici tous les tests passent...
+ <div class="demo">
+ <h1>File test</h1>
+ <div style="padding: 8px; margin-top: 1em; background-color: green; color: white;">1/1 test cases complete.
+ <strong>1</strong> passes, <strong>0</strong> fails and <strong>0</strong> exceptions.</div>
+ </div>
+ La bonne nouvelle, c'est qu'il existe pas mal de points
+ dans la hiérarchie de l'affichage pour créer des sous-classes.
+ </p>
+ <p>
+ Pour l'affichage basé sur des pages web,
+ il y a la classe <span class="new_code">HtmlReporter</span> avec la signature suivante...
+<pre>
+class HtmlReporter extends SimpleReporter {
+ public HtmlReporter($encoding) { ... }
+ public makeDry(boolean $is_dry) { ... }
+ public void paintHeader(string $test_name) { ... }
+ public void sendNoCacheHeaders() { ... }
+ public void paintFooter(string $test_name) { ... }
+ public void paintGroupStart(string $test_name, integer $size) { ... }
+ public void paintGroupEnd(string $test_name) { ... }
+ public void paintCaseStart(string $test_name) { ... }
+ public void paintCaseEnd(string $test_name) { ... }
+ public void paintMethodStart(string $test_name) { ... }
+ public void paintMethodEnd(string $test_name) { ... }
+ public void paintFail(string $message) { ... }
+ public void paintPass(string $message) { ... }
+ public void paintError(string $message) { ... }
+ public void paintException(string $message) { ... }
+ public void paintMessage(string $message) { ... }
+ public void paintFormattedMessage(string $message) { ... }
+ protected string _getCss() { ... }
+ public array getTestList() { ... }
+ public integer getPassCount() { ... }
+ public integer getFailCount() { ... }
+ public integer getExceptionCount() { ... }
+ public integer getTestCaseCount() { ... }
+ public integer getTestCaseProgress() { ... }
+}
+</pre>
+ Voici ce que certaines de ces méthodes veulent dire.
+ Premièrement les méthodes d'affichage que vous voudrez probablement surcharger...
+ <ul class="api">
+ <li>
+ <span class="new_code">HtmlReporter(string $encoding)</span><br>
+ est le constructeur. Notez que le test unitaire initie
+ le lien à l'affichage plutôt que l'opposé.
+ L'affichage est principalement un receveur passif
+ des évènements de tests. Cela permet d'adapter
+ facilement l'affichage pour d'autres systèmes
+ en dehors des tests unitaires, tel le suivi
+ de la charge de serveurs.
+ L'"encoding" est le type d'encodage
+ que vous souhaitez utiliser pour l'affichage du test.
+ Pour pouvoir effectuer un rendu correct de la sortie
+ de débogage quand on utilise le testeur web,
+ il doit correspondre à l'encodage du site testé.
+ Les chaînes de caractères disponibles
+ sont indiquées dans la fonction PHP
+ <a href="http://www.php.net/manual/fr/function.htmlentities.php">html_entities()</a>.
+ </li>
+ <li>
+ <span class="new_code">void paintHeader(string $test_name)</span><br>
+ est appelé une fois, au début du test quand l'évènement
+ de démarrage survient. Le premier évènement de démarrage
+ est souvent délivré par le groupe de tests du niveau
+ le plus haut et donc c'est de là que le
+ <span class="new_code">$test_name</span> arrive.
+ Il peint les titres de la page, CSS, la balise "body", etc.
+ Il ne renvoie rien du tout (<span class="new_code">void</span>).
+ </li>
+ <li>
+ <span class="new_code">void paintFooter(string $test_name)</span><br>
+ est appelé à la toute fin du test pour fermer
+ les balises ouvertes par l'entête de la page.
+ Par défaut il affiche aussi la barre rouge ou verte
+ et le décompte final des résultats.
+ En fait la fin des tests arrive quand l'évènement
+ de fin de test arrive avec le même nom
+ que celui qui l'a initié au même niveau.
+ Le nid des tests en quelque sorte.
+ Fermer le dernier test finit l'affichage.
+ </li>
+ <li>
+ <span class="new_code">void paintMethodStart(string $test_name)</span><br>
+ est appelé au début de chaque méthode de test.
+ Normalement le nom vient de celui de la méthode.
+ Les autres évènements de départ de test
+ se comportent de la même manière sauf que
+ celui du groupe de tests indique au rapporteur
+ le nombre de scénarios de test qu'il contient.
+ De la sorte le rapporteur peut afficher une barre
+ de progrès au fur et à mesure que l'exécuteur
+ passe en revue les scénarios de test.
+ </li>
+ <li>
+ <span class="new_code">void paintMethodEnd(string $test_name)</span><br>
+ clôt le test lancé avec le même nom.
+ </li>
+ <li>
+ <span class="new_code">void paintFail(string $message)</span><br>
+ peint un échec. Par défaut il ne fait qu'afficher
+ le mot "fail", une trace d'arborescence
+ affichant la position du test en cours
+ et le message transmis par l'assertion.
+ </li>
+ <li>
+ <span class="new_code">void paintPass(string $message)</span><br>
+ ne fait rien, par défaut.
+ </li>
+ <li>
+ <span class="new_code">string _getCss()</span><br>
+ renvoie les styles CSS sous la forme d'une chaîne
+ à l'attention de la méthode d'entêtes d'une page.
+ Des styles additionnels peuvent être ajoutés ici
+ si vous ne surchargez pas les entêtes de la page.
+ Vous ne voudrez pas utiliser cette méthode dans
+ des entêtes d'une page surchargée si vous souhaitez
+ inclure le feuille de style CSS d'origine.
+ </li>
+ </ul>
+ Il y a aussi des accesseurs pour aller chercher l'information
+ sur l'état courant de la suite de test. Vous les utiliserez
+ pour enrichir l'affichage...
+ <ul class="api">
+ <li>
+ <span class="new_code">array getTestList()</span><br>
+ est la première méthode très commode pour les sous-classes.
+ Elle liste l'arborescence courante des tests
+ sous la forme d'une liste de noms de tests.
+ Le premier test -- celui le plus proche du coeur --
+ sera le premier dans la liste et la méthode de test
+ en cours sera la dernière.
+ </li>
+ <li>
+ <span class="new_code">integer getPassCount()</span><br>
+ renvoie le nombre de succès atteint. Il est nécessaire
+ pour l'affichage à la fin.
+ </li>
+ <li>
+ <span class="new_code">integer getFailCount()</span><br>
+ renvoie de la même manière le nombre d'échecs.
+ </li>
+ <li>
+ <span class="new_code">integer getExceptionCount()</span><br>
+ renvoie quant à lui le nombre d'erreurs.
+ </li>
+ <li>
+ <span class="new_code">integer getTestCaseCount()</span><br>
+ est le nombre total de scénarios lors de l'exécution des tests.
+ Il comprend aussi les tests groupés.
+ </li>
+ <li>
+ <span class="new_code">integer getTestCaseProgress()</span><br>
+ est le nombre de scénarios réalisés jusqu'à présent.
+ </li>
+ </ul>
+ Une modification simple : demander à l'HtmlReporter d'afficher
+ aussi bien les succès que les échecs et les erreurs...
+<pre><strong>
+class ShowPasses extends HtmlReporter {
+
+ function paintPass($message) {
+ parent::paintPass($message);
+ print "&amp;&lt;span class=\"pass\"&gt;Pass&lt;/span&gt;: ";
+ $breadcrumb = $this-&gt;getTestList();
+ array_shift($breadcrumb);
+ print implode("-&amp;gt;", $breadcrumb);
+ print "-&amp;gt;$message&lt;br /&gt;\n";
+ }
+
+ function _getCss() {
+ return parent::_getCss() . ' .pass { color: green; }';
+ }
+}</strong>
+</pre>
+ </p>
+ <p>
+ Une méthode qui a beaucoup fait jaser reste la méthode <span class="new_code">makeDry()</span>.
+ Si vous lancez cette méthode, sans paramètre,
+ sur le rapporteur avant que la suite de test
+ ne soit exécutée alors aucune méthode de test
+ ne sera appelée. Vous continuerez à avoir
+ les évènements entrants et sortants des méthodes
+ et scénarios de test, mais aucun succès ni échec ou erreur,
+ parce que le code de test ne sera pas exécuté.
+ </p>
+ <p>
+ La raison ? Pour permettre un affichage complexe
+ d'une IHM (ou GUI) qui permettrait la sélection
+ de scénarios de test individuels.
+ Afin de construire une liste de tests possibles,
+ ils ont besoin d'un rapport sur la structure du test
+ pour l'affichage, par exemple, d'une vue en arbre
+ de la suite de test. Avec un rapporteur lancé
+ sur une exécution sèche qui ne renverrait
+ que les évènements d'affichage, cela devient
+ facilement réalisable.
+ </p>
+
+ <p><a class="target" name="autre"><h2>Etendre le rapporteur</h2></a></p>
+ <p>
+ Plutôt que de modifier l'affichage existant,
+ vous voudrez peut-être produire une présentation HTML
+ complètement différente, ou même générer une version texte ou XML.
+ Plutôt que de surcharger chaque méthode dans
+ <span class="new_code">HtmlReporter</span> nous pouvons nous rendre
+ une étape plus haut dans la hiérarchie de classe vers
+ <span class="new_code">SimpleReporter</span> dans le fichier source <em>simple_test.php</em>.
+ </p>
+ <p>
+ Un affichage sans rien, un canevas vierge
+ pour votre propre création, serait...
+<pre><strong>
+require_once('simpletest/simple_test.php');</strong>
+
+class MyDisplay extends SimpleReporter {<strong>
+ </strong>
+ function paintHeader($test_name) {
+ }
+
+ function paintFooter($test_name) {
+ }
+
+ function paintStart($test_name, $size) {<strong>
+ parent::paintStart($test_name, $size);</strong>
+ }
+
+ function paintEnd($test_name, $size) {<strong>
+ parent::paintEnd($test_name, $size);</strong>
+ }
+
+ function paintPass($message) {<strong>
+ parent::paintPass($message);</strong>
+ }
+
+ function paintFail($message) {<strong>
+ parent::paintFail($message);</strong>
+ }
+}
+</pre>
+ Aucune sortie ne viendrait de cette classe jusqu'à un ajout de votre part.
+ </p>
+
+ <p><a class="target" name="cli"><h2>Le rapporteur en ligne de commande</h2></a></p>
+ <p>
+ SimpleTest est aussi livré avec un rapporteur
+ en ligne de commande, minime lui aussi.
+ L'interface imite celle de JUnit,
+ sauf qu'elle envoie les messages d'erreur au fur
+ et à mesure de leur arrivée.
+ Pour utiliser le rapporteur en ligne de commande,
+ il suffit de l'intervertir avec celui de la version HTML...
+<pre>
+&lt;?php
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/reporter.php');
+
+$test = &amp;new GroupTest('File test');
+$test-&gt;addTestFile('tests/file_test.php');
+$test-&gt;run(<strong>new TextReporter()</strong>);
+?&gt;
+</pre>
+ Et ensuite d'invoquer la suite de test à partir d'une ligne de commande...
+<pre class="shell">
+php file_test.php
+</pre>
+ Bien sûr vous aurez besoin d'installer PHP
+ en ligne de commande. Une suite de test qui
+ passerait toutes ses assertions ressemble à...
+<pre class="shell">
+File test
+OK
+Test cases run: 1/1, Failures: 0, Exceptions: 0
+</pre>
+ Un échec déclenche un affichage comme...
+<pre class="shell">
+File test
+1) True assertion failed.
+ in createnewfile
+FAILURES!!!
+Test cases run: 1/1, Failures: 1, Exceptions: 0
+</pre>
+ </p>
+ <p>
+ Une des principales raisons pour utiliser
+ une suite de test en ligne de commande tient
+ dans l'utilisation possible du testeur avec
+ un processus automatisé. Pour fonctionner comme
+ il faut dans des scripts shell le script de test
+ devrait renvoyer un code de sortie non-nul suite à un échec.
+ Si une suite de test échoue la valeur <span class="new_code">false</span>
+ est renvoyée par la méthode <span class="new_code">SimpleTest::run()</span>.
+ Nous pouvons utiliser ce résultat pour terminer le script
+ avec la bonne valeur renvoyée...
+<pre>
+&lt;?php
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/reporter.php');
+
+$test = &amp;new GroupTest('File test');
+$test-&gt;addTestFile('tests/file_test.php');<strong>
+exit ($test-&gt;run(new TextReporter()) ? 0 : 1);</strong>
+?&gt;
+</pre>
+ Bien sûr l'objectif n'est pas de créer deux scripts de test,
+ l'un en ligne de commande et l'autre pour un navigateur web,
+ pour chaque suite de test.
+ Le rapporteur en ligne de commande inclut
+ une méthode pour déterminer l'environnement d'exécution...
+<pre>
+&lt;?php
+require_once('simpletest/unit_tester.php');
+require_once('simpletest/reporter.php');
+
+$test = &amp;new GroupTest('File test');
+$test-&gt;addTestFile('tests/file_test.php');<strong>
+if (TextReporter::inCli()) {</strong>
+ exit ($test-&gt;run(new TextReporter()) ? 0 : 1);<strong>
+}</strong>
+$test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ Il s'agit là de la forme utilisée par SimpleTest lui-même.
+ </p>
+
+ <p><a class="target" name="xml"><h2>Test distant</h2></a></p>
+ <p>
+ SimpleTest est livré avec une classe <span class="new_code">XmlReporter</span>
+ utilisée pour de la communication interne.
+ Lors de son exécution, le résultat ressemble à...
+<pre class="shell">
+&lt;?xml version="1.0"?&gt;
+&lt;run&gt;
+ &lt;group size="4"&gt;
+ &lt;name&gt;Remote tests&lt;/name&gt;
+ &lt;group size="4"&gt;
+ &lt;name&gt;Visual test with 48 passes, 48 fails and 4 exceptions&lt;/name&gt;
+ &lt;case&gt;
+ &lt;name&gt;testofunittestcaseoutput&lt;/name&gt;
+ &lt;test&gt;
+ &lt;name&gt;testofresults&lt;/name&gt;
+ &lt;pass&gt;This assertion passed&lt;/pass&gt;
+ &lt;fail&gt;This assertion failed&lt;/fail&gt;
+ &lt;/test&gt;
+ &lt;test&gt;
+ ...
+ &lt;/test&gt;
+ &lt;/case&gt;
+ &lt;/group&gt;
+ &lt;/group&gt;
+&lt;/run&gt;
+</pre>
+ Vous pouvez utiliser ce format avec le parseur
+ fourni dans SimpleTest lui-même.
+ Il s'agit de <span class="new_code">SimpleTestXmlParser</span>
+ et se trouve <em>xml.php</em> à l'intérieur du paquet SimpleTest...
+<pre>
+&lt;?php
+require_once('simpletest/xml.php');
+
+...
+$parser = &amp;new SimpleTestXmlParser(new HtmlReporter());
+$parser-&gt;parse($test_output);
+?&gt;
+</pre>
+ <span class="new_code">$test_output</span> devrait être au format XML,
+ à partir du rapporteur XML, et pourrait venir
+ d'une exécution en ligne de commande d'un scénario de test.
+ Le parseur envoie des évènements au rapporteur exactement
+ comme tout autre exécution de test.
+ Il y a des occasions bizarres dans lesquelles c'est en fait très utile.
+ </p>
+ <p>
+ Un problème des très grandes suites de test,
+ c'est qu'elles peuvent venir à bout de la limite de mémoire
+ par défaut d'un process PHP - 8Mb.
+ En plaçant la sortie des groupes de test dans du XML
+ et leur exécution dans des process différents,
+ le résultat peut être parsé à nouveau pour agréger
+ les résultats avec moins d'impact sur le test au premier niveau.
+ </p>
+ <p>
+ Parce que la sortie XML peut venir de n'importe où,
+ ça ouvre des possibilités d'agrégation d'exécutions de test
+ depuis des serveur distants.
+ Un scénario de test pour le réaliser existe déjà
+ à l'intérieur du framework SimpleTest, mais il est encore expérimental...
+<pre>
+&lt;?php<strong>
+require_once('../remote.php');</strong>
+require_once('../reporter.php');
+
+$test_url = ...;
+$dry_url = ...;
+
+$test = &amp;new GroupTest('Remote tests');
+$test-&gt;addTestCase(<strong>new RemoteTestCase($test_url, $dry_url)</strong>);
+$test-&gt;run(new HtmlReporter());
+?&gt;
+</pre>
+ <span class="new_code">RemoteTestCase</span> prend la localisation réelle
+ du lanceur de test, tout simplement un page web au format XML.
+ Il prend aussi l'URL d'un rapporteur initié
+ pour effectuer une exécution sèche.
+ Cette technique est employée pour que les progrès
+ soient correctement rapportés vers le haut.
+ <span class="new_code">RemoteTestCase</span> peut être ajouté à
+ une suite de test comme n'importe quel autre groupe de tests.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ L'<a href="http://simpletest.org/api/">API pour développeur de SimpleTest</a>
+ donne tous les détails sur les classes et les assertions disponibles.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/server_stubs_documentation.html b/vendors/simpletest/docs/fr/server_stubs_documentation.html
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendors/simpletest/docs/fr/server_stubs_documentation.html
diff --git a/vendors/simpletest/docs/fr/unit_test_documentation.html b/vendors/simpletest/docs/fr/unit_test_documentation.html
new file mode 100644
index 000000000..ff5475327
--- /dev/null
+++ b/vendors/simpletest/docs/fr/unit_test_documentation.html
@@ -0,0 +1,447 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest pour les tests de régression en PHP</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur les tests unitaires en PHP</h1>
+ This page...
+ <ul>
+<li>
+ <a href="#unitaire">Scénarios de test unitaire</a>
+ et opérations basiques.
+ </li>
+<li>
+ <a href="#extension_unitaire">Étendre des scénarios de test</a>
+ pour les personnaliser à votre propre projet.
+ </li>
+<li>
+ <a href="#lancement_unitaire">Lancer un scénario seul</a>
+ comme un script unique.
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="unitaire"><h2>Scénarios de tests unitaires</h2></a></p>
+ <p>
+ Le coeur du système est un framework de tests de régression
+ construit autour des scénarios de test.
+ Un exemple de scénario de test ressemble à...
+<pre>
+<strong>class FileTestCase extends UnitTestCase {
+}</strong>
+</pre>
+ Si aucun nom de test n'est fourni au moment
+ de la liaison avec le constructeur alors
+ le nom de la classe sera utilisé.
+ Il s'agit du nom qui sera affiché dans les résultats du test.
+ </p>
+ <p>
+ Les véritables tests sont ajoutés en tant que méthode
+ dans le scénario de test dont le nom par défaut
+ commence par la chaîne "test"
+ et quand le scénario de test est appelé toutes les méthodes
+ de ce type sont exécutées dans l'ordre utilisé
+ par l'introspection de PHP pour les trouver.
+ Peuvent être ajoutées autant de méthodes de test que nécessaires.
+ Par exemple...
+<pre>
+require_once('simpletest/autorun.php');
+require_once('../classes/writer.php');
+
+class FileTestCase extends UnitTestCase {
+ function FileTestCase() {
+ $this-&gt;UnitTestCase('File test');
+ }<strong>
+
+ function setUp() {
+ @unlink('../temp/test.txt');
+ }
+
+ function tearDown() {
+ @unlink('../temp/test.txt');
+ }
+
+ function testCreation() {
+ $writer = &amp;new FileWriter('../temp/test.txt');
+ $writer-&gt;write('Hello');
+ $this-&gt;assertTrue(file_exists('../temp/test.txt'), 'File created');
+ }</strong>
+}
+</pre>
+ Le constructeur est optionnel et souvent omis. Sans nom,
+ le nom de la classe est utilisé comme nom pour le scénario de test.
+ </p>
+ <p>
+ Notre unique méthode de test pour le moment est
+ <span class="new_code">testCreation()</span> où nous vérifions
+ qu'un fichier a bien été créé par notre objet
+ <span class="new_code">Writer</span>. Nous pourrions avoir mis
+ le code <span class="new_code">unlink()</span> dans cette méthode,
+ mais en la plaçant dans <span class="new_code">setUp()</span>
+ et <span class="new_code">tearDown()</span> nous pouvons l'utiliser
+ pour nos autres méthodes de test que nous ajouterons.
+ </p>
+ <p>
+ La méthode <span class="new_code">setUp()</span> est lancé
+ juste avant chaque méthode de test.
+ <span class="new_code">tearDown()</span> est lancé après chaque méthode de test.
+ </p>
+ <p>
+ Vous pouvez placer une initialisation de
+ scénario de test dans le constructeur afin qu'elle soit lancée
+ pour toutes les méthodes dans le scénario de test
+ mais dans un tel cas vous vous exposeriez à des interférences.
+ Cette façon de faire est légèrement moins rapide,
+ mais elle est plus sûre.
+ Notez que si vous arrivez avec des notions de JUnit,
+ il ne s'agit pas du comportement auquel vous êtes habitués.
+ Bizarrement JUnit re-instancie le scénario de test
+ pour chaque méthode de test pour se prévenir
+ d'une telle interférence.
+ SimpleTest demande à l'utilisateur final d'utiliser
+ <span class="new_code">setUp()</span>, mais fournit aux codeurs de bibliothèque d'autres crochets.
+ </p>
+ <p>
+ Pour rapporter les résultats de test,
+ le passage par une classe d'affichage - notifiée par
+ les différentes méthodes de type <span class="new_code">assert...()</span> -
+ est utilisée. En voici la liste complète pour
+ la classe <span class="new_code">UnitTestCase</span>,
+ celle par défaut dans SimpleTest...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">assertTrue($x)</span></td>
+<td>Echoue si $x est faux</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertFalse($x)</span></td>
+<td>Echoue si $x est vrai</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNull($x)</span></td>
+<td>Echoue si $x est initialisé</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNotNull($x)</span></td>
+<td>Echoue si $x n'est pas initialisé</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertIsA($x, $t)</span></td>
+<td>Echoue si $x n'est pas de la classe ou du type $t</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertEqual($x, $y)</span></td>
+<td>Echoue si $x == $y est faux</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNotEqual($x, $y)</span></td>
+<td>Echoue si $x == $y est vrai</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertIdentical($x, $y)</span></td>
+<td>Echoue si $x === $y est faux</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNotIdentical($x, $y)</span></td>
+<td>Echoue si $x === $y est vrai</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertReference($x, $y)</span></td>
+<td>Echoue sauf si $x et $y sont la même variable</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertCopy($x, $y)</span></td>
+<td>Echoue si $x et $y sont la même variable</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertWantedPattern($p, $x)</span></td>
+<td>Echoue sauf si l'expression rationnelle $p capture $x</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoUnwantedPattern($p, $x)</span></td>
+<td>Echoue si l'expression rationnelle $p capture $x</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoErrors()</span></td>
+<td>Echoue si une erreur PHP arrive</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertError($x)</span></td>
+<td>Echoue si aucune erreur ou message incorrect de PHP n'arrive</td>
+</tr>
+ </tbody></table>
+ Toutes les méthodes d'assertion peuvent recevoir
+ une description optionnelle :
+ cette description sert pour étiqueter le résultat.
+ Sans elle, une message par défaut est envoyée à la place :
+ il est généralement suffisant.
+ Ce message par défaut peut encore être encadré
+ dans votre propre message si vous incluez "%s"
+ dans la chaîne.
+ Toutes les assertions renvoient vrai / true en cas de succès
+ et faux / false en cas d'échec.
+ </p>
+ <p>
+ D'autres exemples...
+<pre>
+<strong>$variable = null;
+$this-&gt;assertNull($variable, 'Should be cleared');</strong>
+</pre>
+ ...passera et normalement n'affichera aucun message.
+ Si vous avez <a href="http://www.lastcraft.com/display_subclass_tutorial.php">
+ configuré le testeur pour afficher aussi les succès</a>
+ alors le message sera affiché comme tel.
+<pre>
+<strong>$this-&gt;assertIdentical(0, false, 'Zero is not false [%s]');</strong>
+</pre>
+ Ceci échouera étant donné qu'il effectue une vérification
+ sur le type en plus d'une comparaison sur les deux valeurs.
+ La partie "%s" est remplacée par le message d'erreur
+ par défaut qui aurait été affiché si nous n'avions pas fourni le nôtre.
+ Cela nous permet d'emboîter les messages de test.
+<pre>
+<strong>$a = 1;
+$b = $a;
+$this-&gt;assertReference($a, $b);</strong>
+</pre>
+ Échouera étant donné que la variable <span class="new_code">$b</span>
+ est une copie de <span class="new_code">$a</span>.
+<pre>
+<strong>$this-&gt;assertWantedPattern('/hello/i', 'Hello world');</strong>
+</pre>
+ Là, ça passe puisque la recherche est insensible
+ à la casse et que donc <span class="new_code">hello</span>
+ est bien repérable dans <span class="new_code">Hello world</span>.
+<pre>
+<strong>trigger_error('Disaster');
+trigger_error('Catastrophe');
+$this-&gt;assertError();
+$this-&gt;assertError('Catastrophe');
+$this-&gt;assertNoErrors();</strong>
+</pre>
+ Ici, il y a besoin d'une petite explication :
+ toutes passent !
+ </p>
+ <p>
+ Les erreurs PHP dans SimpleTest sont piégées et
+ placées dans une queue. Ici la première vérification
+ d'erreur attrape le message "Disaster"
+ sans vérifier le texte et passe. Résultat :
+ l'erreur est supprimée de la queue.
+ La vérification suivante teste non seulement l'existence
+ de l'erreur mais aussi le texte qui correspond :
+ un autre succès. Désormais la queue est vide
+ et le dernier test passe aussi.
+ Si une autre erreur non vérifiée est encore
+ dans la queue à la fin de notre méthode de test
+ alors une exception sera rapportée dans le test.
+ Notez que SimpleTest ne peut pas attraper les erreurs PHP à la compilation.
+ </p>
+ <p>
+ Les scénarios de test peuvent utiliser des méthodes
+ bien pratiques pour déboguer le code ou pour étendre la suite...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">setUp()</span></td>
+<td>Est lancée avant chaque méthode de test</td>
+</tr>
+ <tr>
+<td><span class="new_code">tearDown()</span></td>
+<td>Est lancée après chaque méthode de test</td>
+</tr>
+ <tr>
+<td><span class="new_code">pass()</span></td>
+<td>Envoie un succès</td>
+</tr>
+ <tr>
+<td><span class="new_code">fail()</span></td>
+<td>Envoie un échec</td>
+</tr>
+ <tr>
+<td><span class="new_code">error()</span></td>
+<td>Envoi un évènement exception</td>
+</tr>
+ <tr>
+<td><span class="new_code">sendMessage()</span></td>
+<td>Envoie un message d'état aux systèmes d'affichage qui le supporte</td>
+</tr>
+ <tr>
+<td><span class="new_code">signal($type, $payload)</span></td>
+<td>Envoie un message défini par l'utilisateur au rapporteur du test</td>
+</tr>
+ <tr>
+<td><span class="new_code">dump($var)</span></td>
+<td>Effectue un <span class="new_code">print_r()</span> formaté pour du déboguage rapide et grossier</td>
+</tr>
+ <tr>
+<td><span class="new_code">swallowErrors()</span></td>
+<td>Vide les erreurs de la queue</td>
+</tr>
+ </tbody></table>
+ </p>
+
+ <p><a class="target" name="extension_unitaire"><h2>Etendre les scénarios de test</h2></a></p>
+ <p>
+ Bien sûr des méthodes supplémentaires de test
+ peuvent être ajoutées pour créer d'autres types
+ de scénario de test afin d'étendre le framework...
+<pre>
+require_once('simpletest/autorun.php');
+<strong>
+class FileTester extends UnitTestCase {
+ function FileTester($name = false) {
+ $this-&gt;UnitTestCase($name);
+ }
+
+ function assertFileExists($filename, $message = '%s') {
+ $this-&gt;assertTrue(
+ file_exists($filename),
+ sprintf($message, 'File [$filename] existence check'));
+ }</strong>
+}
+</pre>
+ Ici la bibliothèque SimpleTest est localisée
+ dans un répertoire local appelé <em>simpletest</em>.
+ Pensez à le modifier pour votre propre environnement.
+ </p>
+ <p>
+ Alternativement vous pourriez utiliser dans votre code
+ un directive <span class="new_code">SimpleTestOptions::ignore('FileTester');</span>.
+ </p>
+ <p>
+ Ce nouveau scénario peut être hérité exactement
+ comme un scénario de test classique...
+<pre>
+class FileTestCase extends <strong>FileTester</strong> {
+
+ function setUp() {
+ @unlink('../temp/test.txt');
+ }
+
+ function tearDown() {
+ @unlink('../temp/test.txt');
+ }
+
+ function testCreation() {
+ $writer = &amp;new FileWriter('../temp/test.txt');
+ $writer-&gt;write('Hello');<strong>
+ $this-&gt;assertFileExists('../temp/test.txt');</strong>
+ }
+}
+</pre>
+ </p>
+ <p>
+ Si vous souhaitez un scénario de test sans
+ toutes les assertions de <span class="new_code">UnitTestCase</span>
+ mais uniquement avec les vôtres propres,
+ vous aurez besoin d'étendre la classe
+ <span class="new_code">SimpleTestCase</span> à la place.
+ Elle se trouve dans <em>simple_test.php</em>
+ en lieu et place de <em>unit_tester.php</em>.
+ A consulter <a href="group_test_documentation.html">plus tard</a>
+ si vous souhaitez incorporer les scénarios
+ d'autres testeurs unitaires dans votre suite de test.
+ </p>
+
+ <p><a class="target" name="lancement_unitaire"><h2>Lancer un unique scénario de test</h2></a></p>
+ <p>
+ Ce n'est pas souvent qu'il faille lancer des scénarios
+ avec un unique test. Sauf lorsqu'il s'agit de s'arracher
+ les cheveux sur un module à problème sans pour
+ autant désorganiser la suite de test principale.
+ Avec <em>autorun</em> aucun échafaudage particulier
+ n'est nécessaire, il suffit de lancer votre test et
+ vous y êtes.
+ </p>
+ <p>
+ Vous pouvez même décider quel rapporteur
+ (par exemple, <span class="new_code">TextReporter</span> ou <span class="new_code">HtmlReporter</span>)
+ vous préférez pour un fichier spécifique quand il est lancé
+ tout seul...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');<strong>
+SimpleTest :: prefer(new TextReporter());</strong>
+require_once('../classes/writer.php');
+
+class FileTestCase extends UnitTestCase {
+ ...
+}
+?&gt;
+</pre>
+ Ce script sera lancé tel que mais il n'y aura
+ aucun succès ou échec avant que des méthodes de test soient ajoutées.
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page de SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API complète de SimpleTest</a>
+ à partir de PHPDoc.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>
diff --git a/vendors/simpletest/docs/fr/web_tester_documentation.html b/vendors/simpletest/docs/fr/web_tester_documentation.html
new file mode 100644
index 000000000..5bb5a9e70
--- /dev/null
+++ b/vendors/simpletest/docs/fr/web_tester_documentation.html
@@ -0,0 +1,566 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Documentation SimpleTest : tester des scripts web</title>
+<link rel="stylesheet" type="text/css" href="docs.css" title="Styles">
+</head>
+<body>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<h1>Documentation sur le testeur web</h1>
+ This page...
+ <ul>
+<li>
+ Réussir à <a href="#telecharger">télécharger une page web</a>
+ </li>
+<li>
+ Tester le <a href="#contenu">contenu de la page</a>
+ </li>
+<li>
+ <a href="#navigation">Naviguer sur un site web</a> pendant le test
+ </li>
+<li>
+ Méthodes pour <a href="#requete">modifier une requête</a> et pour déboguer
+ </li>
+</ul>
+<div class="content">
+ <p><a class="target" name="telecharger"><h2>Télécharger une page</h2></a></p>
+ <p>
+ Tester des classes c'est très bien.
+ Reste que PHP est avant tout un langage
+ pour créer des fonctionnalités à l'intérieur de pages web.
+ Comment pouvons tester la partie de devant
+ -- celle de l'interface -- dans nos applications en PHP ?
+ Etant donné qu'une page web n'est constituée que de texte,
+ nous devrions pouvoir les examiner exactement
+ comme n'importe quelle autre donnée de test.
+ </p>
+ <p>
+ Cela nous amène à une situation délicate.
+ Si nous testons dans un niveau trop bas,
+ vérifier des balises avec un motif ad hoc par exemple,
+ nos tests seront trop fragiles. Le moindre changement
+ dans la présentation pourrait casser un grand nombre de test.
+ Si nos tests sont situés trop haut, en utilisant
+ une version fantaisie du moteur de template pour
+ donner un cas précis, alors nous perdons complètement
+ la capacité à automatiser certaines classes de test.
+ Par exemple, l'interaction entre des formulaires
+ et la navigation devra être testé manuellement.
+ Ces types de test sont extrêmement fastidieux
+ et plutôt sensibles aux erreurs.
+ </p>
+ <p>
+ SimpleTest comprend une forme spéciale de scénario
+ de test pour tester les actions d'une page web.
+ <span class="new_code">WebTestCase</span> inclut des facilités pour la navigation,
+ des vérifications sur le contenu
+ et les cookies ainsi que la gestion des formulaires.
+ Utiliser ces scénarios de test ressemble
+ fortement à <span class="new_code">UnitTestCase</span>...
+<pre>
+<strong>class TestOfLastcraft extends WebTestCase {
+}</strong>
+</pre>
+ Ici nous sommes sur le point de tester
+ le site de <a href="http://www.lastcraft.com/">Last Craft</a>.
+ Si ce scénario de test est situé dans un fichier appelé
+ <em>lastcraft_test.php</em> alors il peut être chargé
+ dans un script de lancement tout comme des tests unitaires...
+<pre>
+&lt;?php
+require_once('simpletest/autorun.php');<strong>
+require_once('simpletest/web_tester.php');</strong>
+SimpleTest::prefer(new TextReporter());
+
+class WebTests extends TestSuite {
+ function WebTests() {
+ $this-&gt;TestSuite('Web site tests');<strong>
+ $this-&gt;addFile('lastcraft_test.php');</strong>
+ }
+}
+?&gt;
+</pre>
+ J'utilise ici le rapporteur en mode texte
+ pour mieux distinguer le contenu au format HTML
+ du résultat du test proprement dit.
+ </p>
+ <p>
+ Rien n'est encore testé. Nous pouvons télécharger
+ la page d'accueil en utilisant la méthode <span class="new_code">get()</span>...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+ <strong>
+ function testHomepage() {
+ $this-&gt;assertTrue($this-&gt;get('http://www.lastcraft.com/'));
+ }</strong>
+}
+</pre>
+ La méthode <span class="new_code">get()</span> renverra "true"
+ uniquement si le contenu de la page a bien été téléchargé.
+ C'est un moyen simple, mais efficace pour vérifier
+ qu'une page web a bien été délivré par le serveur web.
+ Cependant le contenu peut révéler être une erreur 404
+ et dans ce cas notre méthode <span class="new_code">get()</span> renverrait encore un succès.
+ </p>
+ <p>
+ En supposant que le serveur web pour le site Last Craft
+ soit opérationnel (malheureusement ce n'est pas toujours le cas),
+ nous devrions voir...
+<pre class="shell">
+Web site tests
+OK
+Test cases run: 1/1, Failures: 0, Exceptions: 0
+</pre>
+ Nous avons vérifié qu'une page, de n'importe quel type,
+ a bien été renvoyée. Nous ne savons pas encore
+ s'il s'agit de celle que nous souhaitions.
+ </p>
+
+ <p><a class="target" name="contenu"><h2>Tester le contenu d'une page</h2></a></p>
+ <p>
+ Pour obtenir la confirmation que la page téléchargée
+ est bien celle que nous attendions,
+ nous devons vérifier son contenu.
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testHomepage() {<strong>
+ $this-&gt;get('http://www.lastcraft.com/');
+ $this-&gt;assertWantedPattern('/why the last craft/i');</strong>
+ }
+}
+</pre>
+ La page obtenue par le dernier téléchargement est
+ placée dans un buffer au sein même du scénario de test.
+ Il n'est donc pas nécessaire de s'y référer directement.
+ La correspondance du motif est toujours effectuée
+ par rapport à ce buffer.
+ </p>
+ <p>
+ Voici une liste possible d'assertions sur le contenu...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">assertWantedPattern($pattern)</span></td>
+<td>Vérifier une correspondance sur le contenu via une expression rationnelle Perl</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoUnwantedPattern($pattern)</span></td>
+<td>Une expression rationnelle Perl pour vérifier une absence</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertTitle($title)</span></td>
+<td>Passe si le titre de la page correspond exactement</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertLink($label)</span></td>
+<td>Passe si un lien avec ce texte est présent</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoLink($label)</span></td>
+<td>Passe si aucun lien avec ce texte est présent</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertLinkById($id)</span></td>
+<td>Passe si un lien avec cet attribut d'identification est présent</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertField($name, $value)</span></td>
+<td>Passe si une balise input avec ce nom contient cette valeur</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertFieldById($id, $value)</span></td>
+<td>Passe si une balise input avec cet identifiant contient cette valeur</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertResponse($codes)</span></td>
+<td>Passe si la réponse HTTP trouve une correspondance dans la liste</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertMime($types)</span></td>
+<td>Passe si le type MIME se retrouve dans cette liste</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertAuthentication($protocol)</span></td>
+<td>Passe si l'authentification provoquée est de ce type de protocole</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoAuthentication()</span></td>
+<td>Passe s'il n'y pas d'authentification provoquée en cours</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertRealm($name)</span></td>
+<td>Passe si le domaine provoqué correspond</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertHeader($header, $content)</span></td>
+<td>Passe si une entête téléchargée correspond à cette valeur</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoUnwantedHeader($header)</span></td>
+<td>Passe si une entête n'a pas été téléchargé</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertHeaderPattern($header, $pattern)</span></td>
+<td>Passe si une entête téléchargée correspond à cette expression rationnelle Perl</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertCookie($name, $value)</span></td>
+<td>Passe s'il existe un cookie correspondant</td>
+</tr>
+ <tr>
+<td><span class="new_code">assertNoCookie($name)</span></td>
+<td>Passe s'il n'y a pas de cookie avec un tel nom</td>
+</tr>
+ </tbody></table>
+ Comme d'habitude avec les assertions de SimpleTest,
+ elles renvoient toutes "false" en cas d'échec
+ et "true" si c'est un succès.
+ Elles renvoient aussi un message de test optionnel :
+ vous pouvez l'ajouter dans votre propre message en utilisant "%s".
+ </p>
+ <p>
+ A présent nous pourrions effectué le test sur le titre uniquement...
+<pre>
+<strong>$this-&gt;assertTitle('The Last Craft?');</strong>
+</pre>
+ En plus d'une simple vérification sur le contenu HTML,
+ nous pouvons aussi vérifier que le type MIME est bien d'un type acceptable...
+<pre>
+<strong>$this-&gt;assertMime(array('text/plain', 'text/html'));</strong>
+</pre>
+ Plus intéressant encore est la vérification sur
+ le code de la réponse HTTP. Pareillement au type MIME,
+ nous pouvons nous assurer que le code renvoyé se trouve
+ bien dans un liste de valeurs possibles...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testHomepage() {
+ $this-&gt;get('http://simpletest.sourceforge.net/');<strong>
+ $this-&gt;assertResponse(200);</strong>
+ }
+}
+</pre>
+ Ici nous vérifions que le téléchargement s'est
+ bien terminé en ne permettant qu'une réponse HTTP 200.
+ Ce test passera, mais ce n'est pas la meilleure façon de procéder.
+ Il n'existe aucune page sur <em>http://simpletest.sourceforge.net/</em>,
+ à la place le serveur renverra une redirection vers
+ <em>http://www.lastcraft.com/simple_test.php</em>.
+ <span class="new_code">WebTestCase</span> suit automatiquement trois
+ de ces redirections. Les tests sont quelque peu plus
+ robustes de la sorte. Surtout qu'on est souvent plus intéressé
+ par l'interaction entre les pages que de leur simple livraison.
+ Si les redirections se révèlent être digne d'intérêt,
+ il reste possible de les supprimer...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testHomepage() {<strong>
+ $this-&gt;setMaximumRedirects(0);</strong>
+ $this-&gt;get('http://simpletest.sourceforge.net/');
+ $this-&gt;assertResponse(200);
+ }
+}
+</pre>
+ Alors l'assertion échoue comme prévue...
+<pre class="shell">
+Web site tests
+1) Expecting response in [200] got [302]
+ in testhomepage
+ in testoflastcraft
+ in lastcraft_test.php
+FAILURES!!!
+Test cases run: 1/1, Failures: 1, Exceptions: 0
+</pre>
+ Nous pouvons modifier le test pour accepter les redirections...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+
+ function testHomepage() {
+ $this-&gt;setMaximumRedirects(0);
+ $this-&gt;get('http://simpletest.sourceforge.net/');
+ $this-&gt;assertResponse(<strong>array(301, 302, 303, 307)</strong>);
+ }
+}
+</pre>
+ Maitenant ça passe.
+ </p>
+
+ <p><a class="target" name="navigation"><h2>Navigeur dans un site web</h2></a></p>
+ <p>
+ Les utilisateurs ne naviguent pas souvent en tapant les URLs,
+ mais surtout en cliquant sur des liens et des boutons.
+ Ici nous confirmons que les informations sur le contact
+ peuvent être atteintes depuis la page d'accueil...
+<pre>
+class TestOfLastcraft extends WebTestCase {
+ ...
+ function testContact() {
+ $this-&gt;get('http://www.lastcraft.com/');<strong>
+ $this-&gt;clickLink('About');
+ $this-&gt;assertTitle('About Last Craft');</strong>
+ }
+}
+</pre>
+ Le paramètre est le texte du lien.
+ </p>
+ <p>
+ Il l'objectif est un bouton plutôt qu'une balise ancre,
+ alors <span class="new_code">clickSubmit()</span> doit être utilisé avec
+ le titre du bouton...
+<pre>
+<strong>$this-&gt;clickSubmit('Go!');</strong>
+</pre>
+ </p>
+ <p>
+ La liste des méthodes de navigation est...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">get($url, $parameters)</span></td>
+<td>Envoie une requête GET avec ces paramètres</td>
+</tr>
+ <tr>
+<td><span class="new_code">post($url, $parameters)</span></td>
+<td>Envoie une requête POST avec ces paramètres</td>
+</tr>
+ <tr>
+<td><span class="new_code">head($url, $parameters)</span></td>
+<td>Envoie une requête HEAD sans remplacer le contenu de la page</td>
+</tr>
+ <tr>
+<td><span class="new_code">retry()</span></td>
+<td>Relance la dernière requête</td>
+</tr>
+ <tr>
+<td><span class="new_code">back()</span></td>
+<td>Identique au bouton "Précédent" du navigateur</td>
+</tr>
+ <tr>
+<td><span class="new_code">forward()</span></td>
+<td>Identique au bouton "Suivant" du navigateur</td>
+</tr>
+ <tr>
+<td><span class="new_code">authenticate($name, $password)</span></td>
+<td>Re-essaye avec une tentative d'authentification</td>
+</tr>
+ <tr>
+<td><span class="new_code">getFrameFocus()</span></td>
+<td>Le nom de la fenêtre en cours d'utilisation</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocusByIndex($choice)</span></td>
+<td>Change le focus d'une fenêtre en commençant par 1</td>
+</tr>
+ <tr>
+<td><span class="new_code">setFrameFocus($name)</span></td>
+<td>Change le focus d'une fenêtre en utilisant son nom</td>
+</tr>
+ <tr>
+<td><span class="new_code">clearFrameFocus()</span></td>
+<td>Revient à un traitement de toutes les fenêtres comme une seule</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmit($label)</span></td>
+<td>Clique sur le premier bouton avec cette étiquette</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitByName($name)</span></td>
+<td>Clique sur le bouton avec cet attribut de nom</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickSubmitById($id)</span></td>
+<td>Clique sur le bouton avec cet attribut d'identification</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImage($label, $x, $y)</span></td>
+<td>Clique sur une balise input de type image par son titre (title="*") our son texte alternatif (alt="*")</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageByName($name, $x, $y)</span></td>
+<td>Clique sur une balise input de type image par son attribut (name="*")</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickImageById($id, $x, $y)</span></td>
+<td>Clique sur une balise input de type image par son identifiant (id="*")</td>
+</tr>
+ <tr>
+<td><span class="new_code">submitFormById($id)</span></td>
+<td>Soumet un formulaire sans valeur de soumission</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLink($label, $index)</span></td>
+<td>Clique sur une ancre avec ce texte d'étiquette visible</td>
+</tr>
+ <tr>
+<td><span class="new_code">clickLinkById($id)</span></td>
+<td>Clique sur une ancre avec cet attribut d'identification</td>
+</tr>
+ </tbody></table>
+ </p>
+ <p>
+ Les paramètres dans les méthodes <span class="new_code">get()</span>,
+ <span class="new_code">post()</span> et <span class="new_code">head()</span> sont optionnels.
+ Le téléchargement via HTTP HEAD ne modifie pas
+ le contexte du navigateur, il se limite au chargement des cookies.
+ Cela peut être utilise lorsqu'une image ou une feuille de style
+ initie un cookie pour bloquer un robot trop entreprenant.
+ </p>
+ <p>
+ Les commandes <span class="new_code">retry()</span>, <span class="new_code">back()</span>
+ et <span class="new_code">forward()</span> fonctionnent exactement comme
+ dans un navigateur. Elles utilisent l'historique pour
+ relancer les pages. Une technique bien pratique pour
+ vérifier les effets d'un bouton retour sur vos formulaires.
+ </p>
+ <p>
+ Les méthodes sur les fenêtres méritent une petite explication.
+ Par défaut, une page avec des fenêtres est traitée comme toutes
+ les autres. Le contenu sera vérifié à travers l'ensemble de
+ la "frameset", par conséquent un lien fonctionnera,
+ peu importe la fenêtre qui contient la balise ancre.
+ Vous pouvez outrepassé ce comportement en exigeant
+ le focus sur une unique fenêtre. Si vous réalisez cela,
+ toutes les recherches et toutes les actions se limiteront
+ à cette unique fenêtre, y compris les demandes d'authentification.
+ Si un lien ou un bouton n'est pas dans la fenêtre en focus alors
+ il ne peut pas être cliqué.
+ </p>
+ <p>
+ Tester la navigation sur des pages fixes ne vous alerte que
+ quand vous avez cassé un script entier.
+ Pour des pages fortement dynamiques,
+ un forum de discussion par exemple,
+ ça peut être crucial pour vérifier l'état de l'application.
+ Pour la plupart des applications cependant,
+ la logique vraiment délicate se situe dans la gestion
+ des formulaires et des sessions.
+ Heureusement SimpleTest aussi inclut
+ <a href="form_testing_documentation.html">
+ des outils pour tester des formulaires web</a>.
+ </p>
+
+ <p><a class="target" name="requete"><h2>Modifier la requête</h2></a></p>
+ <p>
+ Bien que SimpleTest n'ait pas comme objectif
+ de contrôler des erreurs réseau, il contient quand même
+ des méthodes pour modifier et déboguer les requêtes qu'il lance.
+ Voici une autre liste de méthode...
+ <table><tbody>
+ <tr>
+<td><span class="new_code">getTransportError()</span></td>
+<td>La dernière erreur de socket</td>
+</tr>
+ <tr>
+<td><span class="new_code">getUrl()</span></td>
+<td>La localisation courante</td>
+</tr>
+ <tr>
+<td><span class="new_code">showRequest()</span></td>
+<td>Déverse la requête sortante</td>
+</tr>
+ <tr>
+<td><span class="new_code">showHeaders()</span></td>
+<td>Déverse les entêtes d'entrée</td>
+</tr>
+ <tr>
+<td><span class="new_code">showSource()</span></td>
+<td>Déverse le contenu brut de la page HTML</td>
+</tr>
+ <tr>
+<td><span class="new_code">ignoreFrames()</span></td>
+<td>Ne recharge pas les framesets</td>
+</tr>
+ <tr>
+<td><span class="new_code">setCookie($name, $value)</span></td>
+<td>Initie un cookie à partir de maintenant</td>
+</tr>
+ <tr>
+<td><span class="new_code">addHeader($header)</span></td>
+<td>Ajoute toujours cette entête à la requête</td>
+</tr>
+ <tr>
+<td><span class="new_code">setMaximumRedirects($max)</span></td>
+<td>S'arrête après autant de redirections</td>
+</tr>
+ <tr>
+<td><span class="new_code">setConnectionTimeout($timeout)</span></td>
+<td>Termine la connexion après autant de temps entre les bytes</td>
+</tr>
+ <tr>
+<td><span class="new_code">useProxy($proxy, $name, $password)</span></td>
+<td>Effectue les requêtes à travers ce proxy d'URL</td>
+</tr>
+ </tbody></table>
+ </p>
+
+ </div>
+ References and related information...
+ <ul>
+<li>
+ La page du projet SimpleTest sur
+ <a href="http://sourceforge.net/projects/simpletest/">SourceForge</a>.
+ </li>
+<li>
+ La page de téléchargement de SimpleTest sur
+ <a href="http://www.lastcraft.com/simple_test.php">LastCraft</a>.
+ </li>
+<li>
+ <a href="http://simpletest.org/api/">L'API du développeur pour SimpleTest</a>
+ donne tous les détails sur les classes et les assertions disponibles.
+ </li>
+</ul>
+<div class="menu_back"><div class="menu">
+<a href="index.html">SimpleTest</a>
+ |
+ <a href="overview.html">Overview</a>
+ |
+ <a href="unit_test_documentation.html">Unit tester</a>
+ |
+ <a href="group_test_documentation.html">Group tests</a>
+ |
+ <a href="mock_objects_documentation.html">Mock objects</a>
+ |
+ <a href="partial_mocks_documentation.html">Partial mocks</a>
+ |
+ <a href="reporter_documentation.html">Reporting</a>
+ |
+ <a href="expectation_documentation.html">Expectations</a>
+ |
+ <a href="web_tester_documentation.html">Web tester</a>
+ |
+ <a href="form_testing_documentation.html">Testing forms</a>
+ |
+ <a href="authentication_documentation.html">Authentication</a>
+ |
+ <a href="browser_documentation.html">Scriptable browser</a>
+</div></div>
+<div class="copyright">
+ Copyright<br>Marcus Baker 2006
+ </div>
+</body>
+</html>