mardi 25 octobre 2016

Reflection Exception Class filesystem does not exist

I am creating a test for a class that uses the Storage facade in Laravel 5. I Get the error, "ReflectionException: Class filesystem does not exist" when I run the test.

Here is the code for the test

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

use Illuminate\Support\Facades\Storage as Storage;
use App\Fourpoint\services\Material;

use \Illuminate\Container\Container as Container;
use \Illuminate\Support\Facades\Facade as Facade;

class MaterialServiceTest extends TestCase
{
use DatabaseMigrations;

protected $directory;
protected $file;

public function setUp(){

    $app = new Container();
    $app->singleton('app', 'Illuminate\Container\Container');

    Facade::setFacadeApplication($app);

    $this -> mat = new \App\FourPoint\services\Material();
    $this -> directory = 'home/Code/project4point/tests/mockFiles';

    $this -> file = new \Symfony\Component\HttpFoundation\File\UploadedFile('tests/mockFiles/testPDF.pdf', 'testPDF.pdf');

}

public function testNewMaterial(){

    Storage::shouldReceive('put')
        ->andReturn(true);

    Storage::shouldReceive('exists')
        ->andReturn(true);

    $this -> mat->newMaterial('pdf',1,1,'testPDF',$this -> file,1,1);

}
}

The error is caused by "Storage::shouldReceive('put')"



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire