2.ติดตั้งไว้ใน htdocs
3.สร้างโฟลเดอร์ไว้สำหรับเก็บไฟล์สำหรับนำไปเทส
4.สร้างไฟล์ phpไว้สำหรับนำไปเทส
โค้ด: เลือกทั้งหมด
<?php
// src/fortest/Calculator.php
namespace md\testtest;
class Calculator
{
public function add($a, $b)
{
return $a + $b;
}
}
?>
โค้ด: เลือกทั้งหมด
<?php
// src/Acme/DemoBundle/Tests/Utility/CalculatorTest.php
namespace md\testtest;
use md\testtest\Calculator;
class CalculatorTest extends \PHPUnit_Framework_TestCase
{
public function testAdd()
{
$calc = new Calculator();
$result = $calc->add(30, 12);
// assert that your calculator added the numbers correctly!
$this->assertEquals(42, $result);
}
public function testAdd2()
{
$calc = new Calculator();
$result = $calc->add(30, 13);
// assert that your calculator added the numbers correctly!
$this->assertEquals(42, $result);
}
public function testAdd3()
{
$calc = new Calculator();
$result = $calc->add(30, 10);
// assert that your calculator added the numbers correctly!
$this->assertEquals(40, $result);
}
}
9.เลือก phpunit 10.เลือกไฟล์ bootstrap.php.cache และ phpunit.xml.dist
11.คลิกขวาที่ไฟล์ที่จะนำไปเทส กด test 12.ผลเทส