Ajout projet webAduc
This commit is contained in:
30
Sources/webAduc/tests/unit/01-loginTest.php
Normal file
30
Sources/webAduc/tests/unit/01-loginTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once('www/src/class/userClass.php');
|
||||
|
||||
// Test de la class userClass
|
||||
|
||||
class unitLoginTestextendsPHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testValidUser()
|
||||
{
|
||||
// Create a stub for the SomeClass class.
|
||||
$stub=$this->getMockBuilder('db')->setMethods(array('dbQuery','dbNumRows'))->disableOriginalConstructor()->getMock();
|
||||
// Configure the stub.
|
||||
$stub->expects($this->any())->method('dbQuery')->with($this->equalTo("SELECT * FROM Users WHERE login='user' AND passwd='".md5('password')."';"))->will($this->returnValue('TRUE'));
|
||||
$stub->expects($this->any())->method('dbNumRows')->will($this->returnValue(1));
|
||||
$user=new classUser($stub);
|
||||
$this->assertTrue($user->userIsValid("user","password"));
|
||||
}
|
||||
|
||||
public function testNotValidUser()
|
||||
{
|
||||
// Create a stub for the SomeClass class.
|
||||
$stub=$this->getMockBuilder('db')->setMethods(array('dbQuery','dbNumRows'))->disableOriginalConstructor()->getMock();
|
||||
// Configure the stub.
|
||||
$stub->expects($this->any())->method('dbQuery')->with($this->equalTo("SELECT * FROM Users WHERE login='user' AND passwd='".md5('pwd')."';"))->will($this->returnValue('TRUE'));
|
||||
$stub->expects($this->any())->method('dbNumRows')->will($this->returnValue(0));
|
||||
$user=new classUser($stub);
|
||||
$this->assertFalse($user->userIsValid("user","pwd"));
|
||||
}
|
||||
|
||||
}
|
||||
1
Sources/webAduc/tests/unit/README.txt
Normal file
1
Sources/webAduc/tests/unit/README.txt
Normal file
@@ -0,0 +1 @@
|
||||
Placer les tests unitaires dans ce répertoire
|
||||
20
Sources/webAduc/tests/unit/phpunit.xml
Normal file
20
Sources/webAduc/tests/unit/phpunit.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
|
||||
bootstrap="www/src/lib/autoload.php"
|
||||
backupGlobals="false"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite>
|
||||
<directory suffix="Test.php">tests/unit</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">www</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
66
Sources/webAduc/tests/unit/skeleton.php
Normal file
66
Sources/webAduc/tests/unit/skeleton.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Exemple de test unitaire
|
||||
*/
|
||||
// Call MyClassTest::main() if this source file is executed directly.
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'MyClassTest::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
|
||||
require_once 'MyClass.php';
|
||||
|
||||
/**
|
||||
* Test class for MyClass.
|
||||
* Generated by PHPUnit on 2007-08-11 at 20:01:00.
|
||||
*/
|
||||
class MyClassTest extends PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Runs the test methods of this class.
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
public static function main() {
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
|
||||
$suite = new PHPUnit_Framework_TestSuite('MyClassTest');
|
||||
$result = PHPUnit_TextUI_TestRunner::run($suite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function setUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function tearDown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testMyMethod().
|
||||
*/
|
||||
public function testMyMethod() {
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Call MyClassTest::main() if this source file is executed directly.
|
||||
if (PHPUnit_MAIN_METHOD == 'MyClassTest::main') {
|
||||
MyClassTest::main();
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user