Created
October 25, 2016 02:16
-
-
Save emanuellarini/ea6f84687b4202db3497211442b8b138 to your computer and use it in GitHub Desktop.
Test file store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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