Actually working on a Bootstrap 3 plugin, everythinks works now. I want to test everything developping test with php Unit !
But when i call php unit it say that he don't found the class like that :
Fatal error : Class 'BsHelpers\\View\\Helper\\BsHelper' not found in C:\\wamp3\\www\\wac_lucien\\BsHelpers\\BsHelpersCakePHP3\\3.2\\plugins\\BsHelpers\\tests\\TestCase\\View\\Helper\\BsHelpersTest.php on line 26
So after trying to follow exactly the documentation from CakePHP3 i meet the problem at the begenning. For now I only got that :
<?php
namespace BsHelpers\Test\TestCase\View\Helper;
use BsHelpers\View\Helper\BsHelper;
use Cake\TestSuite\TestCase;
use Cake\View\View;
class BsHelperTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->View = new View();
$this->Bs = new BsHelper($this->View);
}
public function testBar()
{
}
}
I think problem can be in bootstrap.php. The path of the plugin loader can be false but i don't know how to set up...
Plugin::load('BsHelpers', ['path' => ROOT . DS]);
In the composer.json of my plugin i got :
"autoload": {
"psr-4": {
"App\\": "src",
"BsHelpers\\": "./plugins/BsHelpers/src",
"BsHelpers\\Test\\": "./plugins/BsHelpers/tests"
}
},
I invoke php unit test doing ( in my plugin folder )
vendor\bin\phpunit
And my phpunit.xml.dist looks like
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>
<testsuites>
<testsuite name="BsHelpers Test Cases">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
Any idea of why i can't acces my Helper during running my test ?
Pls guys I really need ideas
UPDATE
I tried again running tests. I found the error and change the line, but I don't understand why that was giving issues in tests.
Initialy I tried to understand CakePHP3 plugins, by working with this plugin from friendsofcake , when i made my plugin (to insert more functionalities) I just copied the composer.json to see the result with my plugin. Just forget to change that part.
So error was in the composer.json of the plugin :
{
"name": "friendsofcake/bootstrap-ui",
"description": "Twitter Bootstrap 3 support for CakePHP 3",
"type": "cakephp-plugin"
}
I changed the name line with
"name": "lucienleroux/bs-helpers",
And I really don't understand why that solved the problem because nowhere I am setting a name like "lucienleroux/bs-helpers" in my plugin. And in fact it works with any other string like "test/bs_helpers" ... If you understand I am interested in the answer !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.