Skip to content

Instantly share code, notes, and snippets.

@emanuellarini
Created October 25, 2016 02:16
Show Gist options
  • Save emanuellarini/ea6f84687b4202db3497211442b8b138 to your computer and use it in GitHub Desktop.
Save emanuellarini/ea6f84687b4202db3497211442b8b138 to your computer and use it in GitHub Desktop.
Test file store
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExcelFileRepositoryTest extends TestCase
{
use DatabaseMigrations;
protected $mockFile;
protected $uploadedFile;
public function setUp()
{
parent::setUp();
$this->mockFile = \Mockery::mock(App\Models\Contracts\ExcelFileRepositoryTest::class);
App::instance(App\Repositories\Contracts\ExcelFileRepositoryTest::class, $this->mockFile);
$this->uploadedFile = new Symfony\Component\HttpFoundation\File\UploadedFile(storage_path('app/teste_true.xlsx'), 'teste_true.xlsx', '', '', '', true);
}
public function test_store_file()
{
$excelFile = App::make(App\Models\ExcelFile::class);
$this->mockFile->shouldReceive('store')->with($this->uploadedFile)->once()->andReturn($excelFile->first());
$this->assertEquals($this->mockFile->store($this->uploadedFile), $excelFile->first());
}
public function tearDown()
{
parent::tearDown();
\Mockery::close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment