public function testUploads() { $model = 'C4tech\\Upload\\Model'; Upload::shouldReceive('getModelClass')->withNoArgs()->once()->andReturn($model); $this->verifyMorphMany('uploads', $model, 'uploadable'); }
public function testGetUploads() { $tag = 'test-tag'; $object = Mockery::mock('C4tech\\Upload\\Contracts\\UploadModelInterface'); $new_object = 'Demo!'; $collection = Mockery::mock('Illuminate\\Support\\Collection[map]', [[$object]]); $new_collection = 'TestCollection'; $this->repo->shouldReceive('getTags')->with('uploads')->once()->andReturn([$tag]); $this->repo->shouldReceive('getCacheId')->with('uploads')->once()->andReturn($tag); $this->repo->shouldReceive('uploads->get')->withNoArgs()->once()->andReturn($collection); Upload::shouldReceive('make')->with($object)->once()->andReturn($new_object); $collection->shouldReceive('map')->with(Mockery::on(function ($closure) use($object, $new_object) { expect($closure($object))->equals($new_object); return true; }))->once()->andReturn($new_collection); Cache::shouldReceive('tags->remember')->with([$tag])->with($tag, Mockery::type('integer'), Mockery::on(function ($closure) use($new_collection) { expect($closure())->equals($new_collection); return true; }))->once()->andReturn(true); expect($this->repo->getUploads())->true(); }