[英]phpunit impossible to follow the installation process
我在嘗試安裝phpunit時遇到很多問題,也許我的知識還不夠,或者指南很不完整。
首先,在安裝過程中,我嘗試使用“直接下載的PHAR文件”或“ sudo apt-get install phpunit
”在全球進行所有嘗試,但是當我嘗試這樣做時:
$phpunit -v
bash: /usr/bin/phpunit: No chuch file or directory
如果我做:
$ ll /usr/local/bin (I know, the path is different, other unexplicable event)
-rwxr-xr-x 1 user user 2784899 abr 29 17:09 phpunit*
但
$ sudo phpunit --version
PHPUnit 7.1.5 by Sebastian Bergmann adn contributors.
好,看起來更好,所以我嘗試舉第一個例子
<?php
use PHPUnit\Framework\TestCase;
class StackTest extends TestCase
{
public function testPushAndPop()
{
$stack = [];
$this->assertSame(0, count($stack));
array_push($stack, 'foo');
$this->assertSame('foo', $stack[count($stack)-1]);
$this->assertSame(1, count($stack));
$this->assertSame('foo', array_pop($stack));
$this->assertSame(0, count($stack));
}
}
但這給了我下一個錯誤:
PHP Fatal error: Class 'PHPUnit\Framework\Testcase' not found in /var/www/html/phpunit/index.php on line 4
我正在使用Ubuntu 18和php 7.2
任何想法?
從命令行運行PHPUnit時,還需要包含一個“ bootstrap”文件-它可以像composer autoload.php文件一樣簡單:
phpunit --bootstrap vendor/autoload.php
從長遠來看,該配置將放置在phpunit.xml文件中,以便讀取並由PHPunit自動運行。
<!-- file: phpunit.xml
src/autoload.php would also include the ./vendor/autoload.php file
and do any other locally required setup -->
<phpunit bootstrap="src/autoload.php">
<testsuites>
<testsuite name="money">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.