Folder structure
/app/lib/Helper.php
/tests/HelperTest.php
/vendor/autoload.php
composer.json
{
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"psr-4": {
"Datapark\\LPS\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Datapark\\LPS\\Tests\\": "tests/"
}
},
}
helper.php
<?php
namespace lib;
class Helper
{
public function array_get($array, $key, $default = null)
{
}
}
HelperTest.php
<?php
use lib\Helper;
class HelperTest extends \PHPUnit_Framework_TestCase
{
public function test_array_get()
{
$helper = new Helper();
}
}
Command executed on server
[Debian 8 / PHP7]
phpunit-bootstrap vendor / autoload.php tests
The error I get
1) HelperTest :: test_array_get
Error: class 'lib \ Helper' not found
lib \ Helper loads through the namespace, and my IDE (PhpStorm) also recognizes it. Fighting around for several hours and not getting him to work.
source
share