Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<?php
require_once('PHPUnit/Framework/TestSuite.php');
require_once('PHPUnit/Framework/TestResult.php');
require_once('PHPUnit/Util/Log/XML.php');
require_once('ArrayTest.php');
class MyTestRunner
{
public static function run()
{
// Create the test suite instance
$suite = new PHPUnit_Framework_TestSuite();
$suite->setName('MyTestRunner');
// Add files to the TestSuite
$suite->addTestSuite('ArrayTest');
// Create a xml listener object
$listener = new PHPUnit_Util_Log_XML;
// Create TestResult object and pass the xml listener to it
$testResult = new PHPUnit_Framework_TestResult();
$testResult->addListener($listener);
// Run the TestSuite
$result = $suite->run($testResult);
// Get the results from the listener
$xml_result = $listener->getXML();
return $xml_result;
}
}
<?php
require_once 'PHPUnit2/Framework/TestCase.php';
require_once 'PHPUnit2/Framework/IncompleteTestError.php';
require_once 'PHPUnit2/Util/Log/XML.php';
require_once 'BankAccount.php';
class BankAccountTest extends PHPUnit2_Framework_TestCase
{
private $ba;
private $logger = NULL;
function __construct()
{
$this->logger = new PHPUnit2_Util_Log_XML();
$this->logger->setWriteDocument(false);
print ("\r\n");print ("\r\n");print ("\r\n");
}
function __destruct()
{
$this->logger = NULL;
}
protected function setUp()
{
$this->ba = new BankAccount;
}
public function testBalanceIsInitiallyZero()
{
$this->assertEquals(false, $this->ba->getBalance());
}
public function testBalanceCannotBecomeNegative()
{
try
{
$this->ba->withdrawMoney(1);
}
catch (Exception $e) {
return;
}
$this->fail();
}
public function testBalanceCannotBecomeNegative2()
{
try
{
$this->ba->depositMoney(-1);
}
catch (Exception $e)
{
return;
}
$this->fail();
}
public function testBalanceCannotBecomeNegative3()
{
try
{
$this->ba->setBalance(-1);
}
catch (Exception $e)
{
return;
}
$this->fail();
}
public function testUserLogIn()
{
$this->assertEquals(false, $this->ba->userLogIn("123454","00000"));
$this->assertEquals(true, $this->ba->userLogIn("123456789","4321"));
$this->assertEquals(false, $this->ba->userLogIn("12xxx3456789","4321"));
$this->assertEquals(false, $this->ba->userLogIn("",""));
}
public function testSomething()
{
// Optional: Testen Sie hier, was Sie möchten.
$this->assertTrue(TRUE, "Dies sollte bereits funktionieren.");
// Test anhalten und als unvollständig markieren.
// Hierzu können Sie jede Ausnahme verwenden, die die
// Schnittstelle PHPUnit2_Framework_IncompleteTest implementiert.
throw new PHPUnit2_Framework_IncompleteTestError
(
"Dieser Test ist noch nicht fertig ausprogrammiert."
);
$this->fail('Eine erwartete Ausnahme wurde nicht ausgelöst.');
}
}
?>
require_once('PHPUnit2/Framework/TestSuite.php');
require_once('PHPUnit2/Framework/TestResult.php');
require_once('PHPUnit2/Util/Log/XML.php');
require_once('BankAccount.php');
class myTestRunner
{
public static function run()
{
$suite = new PHPUnit_Framework_TestSuite();
$TestClass = new BankAccount;
$suite->setName('MyTestRunner');
// Add files to the TestSuite
$suite->addTestSuite('BankAccount');
// Create a xml listener object
$listener = new PHPUnit_Util_Log_XML;
// Create TestResult object and pass the xml listener to it
$testResult = new PHPUnit_Framework_TestResult();
$testResult->addListener($listener);
// Run the TestSuite
$result = $suite->run($testResult);
// Get the results from the listener
$xml_result = $listener->getXML();
return $xml_result;
}
public function testBalanceIsInitiallyZero()
{
$this->assertEquals(false, $TestClass->getBalance());
}
}
class myTestRunner
{
public function __construct()
{
// Empty constructor to fulfill the requirements of PHPUnit
}
public static function run()