Aug 7, 2016
0
Level 11
Test Failing on Project-Flyer
Not sure what's happening, but I am running Laravel 5.2. So, that could be a problem, but I am very uncertain as I have never written a test before so I wouldn't understand how to read the error. I mean, it obviously has something to do with the move method or something. Anyhoo...
AddPhotoToFlyerTest.php
<?php
// namespace App;
use App\AddPhotoToFlyer;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Mockery as m;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class AddPhotoToFlyerTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function test_it_processes_a_form_to_add_a_photo_to_a_flyer()
{
$flyer = factory(App\Flyer::class)->create();
$file = m::mock(UploadedFile::class, [
'getClientOriginalName' => 'foo',
'getClientOriginalExtension' => 'jpg'
]);
$file->shouldReceive('move')
->once()
->with('flyer_imgs/photos', 'nowfoo.jpg');
$thumbnail = m::mock(App\Thumbnail::class);
$thumbnail->shouldReceive('make')
->once()
->with('flyer_imgs/photos/nowfoo.jpg', 'flyer_imgs/photos/tn-nowfoo.jpg');
(new AddPhotoToFlyer($flyer, $file, $thumbnail))->save();
$this->assertCount(1, $flyer->photos);
}
}
My test results after running:
~/Code/project-flyer$ phpunit tests/AddPhotoToFlyerTest.php
PHPUnit 4.8.27 by Sebastian Bergmann and contributors.
E
Time: 2.42 seconds, Memory: 12.00MB
There was 1 error:
1) AddPhotoToFlyerTest::test_it_processes_a_form_to_add_a_photo_to_a_flyer
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_0_Symfony_Component_HttpFoundation_File_UploadedFile::move("flyer_imgs/photos", "e7f9df49b044ff56c627d8ef1f851a045e90f206.jpg"). Either the method was unexpected or its arguments matched no expected argument list for this method
/home/vagrant/Code/project-flyer/vendor/mockery/mockery/library/Mockery/ExpectationDirector.php:93
/home/vagrant/Code/project-flyer/app/AddPhotoToFlyer.php:26
/home/vagrant/Code/project-flyer/tests/AddPhotoToFlyerTest.php:39
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
Please or to participate in this conversation.