我是使用這個框架的新手,並且在測試插件時發現了一個問題。CakePHP3插件測試類'Cake TestSuite IntegrationTestCase'找不到
PHP Fatal error: Class 'Cake\TestSuite\IntegrationTestCase' not found in /var/www/MyApp/plugins/MyPlugin/tests/TestCase/Controller/UsersControllerTest.php on line 11
運行主應用程序工作正常,但我對插件的所有測試類都有同樣的問題。
測試的類的頭是類似於:
<?php
namespace MyPlugin\Test\TestCase\Controller;
use Cake\TestSuite\IntegrationTestCase;
use MyPlugin\Controller\UsersController;
class UsersControllerTest extends IntegrationTestCase
{
插件的phpunit.xml.dist:
<?xml version="1.0" encoding="UTF-8"?><phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="MyPlugin Test Suite">
<directory>./tests/TestCase</directory>
</testsuite>
</testsuites>
<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector"
file="../../vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<!-- Prevent coverage reports from looking in tests and vendors -->
<filter>
<blacklist>
<directory suffix=".php">./vendor/</directory>
<directory suffix=".ctp">./vendor/</directory>
<directory suffix=".php">./tests/</directory>
<directory suffix=".ctp">./tests/</directory>
</blacklist>
</filter></phpunit>
而且composer.json:
{
"name": "your-name-here/MyPlugin",
"description": "MyPlugin plugin for CakePHP",
"type": "cakephp-plugin",
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "~3.0"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"psr-4": {
"MyPlugin\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"MyPlugin\\Test\\": "tests",
"Cake\\Test\\": "/var/www/MyApp/vendor/cakephp/cakephp/tests",
}
}
}
在此先感謝! ;)
謝謝,但我試過了,它似乎沒有工作。另外,我想在每個想要測試的插件中獲取所有cakephp核心庫是相當多餘的,我無法弄清楚解決方案。 –