徐文志
composer require phpunit/phpunitphpunit.xml : PHPUnit的配置文件
tests : 测试用例目录
1|<?xml version="1.0" encoding="UTF-8"?>
2|<phpunit backupGlobals="false"
3| backupStaticAttributes="false"
4| bootstrap="./config/loader.php"
5| colors="true"
6| convertErrorsToExceptions="true"
7| convertNoticesToExceptions="true"
8| convertWarningsToExceptions="true"
9| processIsolation="false"
10| stopOnFailure="false">
11| <testsuites>
12| <testsuite name="Application Test Suite">
13| <directory suffix="Test.php">./tests</directory>
14| </testsuite>
15| </testsuites>
16| <logging>
17| <log type="coverage-html" target="./phpunit_report" charset="UTF-8"
18| yui="true" highlight="true"
19| lowUpperBound="50" highLowerBound="80" />
20| </logging>
21| <filter>
22| <whitelist processUncoveredFilesFromWhitelist="true">
23| <directory suffix=".php">./app</directory>
24| <exclude>
25|
26| </exclude>
27| </whitelist>
28| </filter>
29| <php>
30| <env name="APP_MODE" value="testing"/>
31| </php>
32|</phpunit><?php
// tests/UtilCase.php
use App\Providers\Util;
class UtilTest extends TestCase
{
public function testCamelToUnderScore()
{
$data = 'abcDeFGhiJk';
$this->assertTrue(Util::camelCaseToUnderScore($data) === 'abc_de_fghi_jk');
}
}./vender/bin/phpunit./tests/*Test.phppublic function test*()
{
//...test code
}public function test*()
{
//...test code
}public function test*()
{
//...test code
}Load phpunit.xml+
也不一定非得是👆