Hi PLEASE SOMEONE CAN HELP ME,I'm noob in testing and I ran a test using PHPunit test and I got this error message
Error: Class 'App\Pages' not found //Summary of non-successful tests: Error: Class 'App\Pages' not found C:\xampp\htdocs\apptest\tests\PagesTest.php:8
Directory structure :
/apptest
|app
Pages.php
|tests
PagesTest.php
|vendor
composer.json
composer.lock
index.php(bootstrap file)
Composer.json Config:
{
"require": {
"phpunit/phpunit": "^8.5"
},
"autoload":{
"psr-4": {
"App\\":"app/"
}
}
Pages.php file code:
<?php
namespace App;
class Pages{
public function getPage($id){
return 'Hello';
}
}
PagesTest.php code:
<?php
use PHPUnit\Framework\TestCase;
class PagesTest extends TestCase{
protected $pages;
protected function setUp():void{
$this->pages = new App\Pages();
}
/**
* @test
*/
public function homePageReturnHello(){
$excepted = 'Hello';
$actual = $pages->getPage('1');
$this->assertEquals($excepted, $actual);
}
}
Aucun commentaire:
Enregistrer un commentaire