public function testListenToUploadModelClosure() { $model = Mockery::mock('UploadableModel'); $repository = Mockery::mock('C4tech\\Upload\\Contracts\\UploadInterface'); $repository->id = 16; $tags = ['tags']; $upload = Mockery::mock('UploadInstance'); $uploadable = Mockery::mock('C4tech\\Upload\\Contracts\\UploadableModelInterface'); $this->repo->shouldReceive('getModelClass')->withNoArgs()->once()->andReturn($model); Config::shouldReceive('get')->with('app.debug')->twice()->andReturn(true); Log::shouldReceive('debug')->with(Mockery::type('string'), Mockery::type('array'))->twice(); $model->shouldReceive('updated'); $model->shouldReceive('deleted'); Upload::shouldReceive('getModelClass')->withNoArgs()->once()->andReturn($upload); $upload->shouldReceive('updated'); $upload->shouldReceive('deleted')->with(Mockery::on(function ($closure) use($upload) { expect_not($closure($upload)); return true; })); Upload::shouldReceive('make')->with($upload)->once()->andReturn($repository); $repository->shouldReceive('getTags')->with($model)->once()->andReturn($tags); Cache::shouldReceive('tags->flush')->with($tags)->withNoArgs()->once(); $this->repo->shouldReceive('withUpload')->with($repository)->once()->andreturn([$uploadable]); $uploadable->shouldReceive('getModel->touch')->withNoArgs()->once(); expect_not($this->repo->listenToUpload()); }
function __construct() { $this->application = m::mock('Illuminate\\Foundation\\Application'); $this->databaseHelper = m::mock('Label305\\AujaLaravel\\Database\\DatabaseHelper'); $this->aujaConfigurator = new AujaConfigurator($this->application, $this->databaseHelper); Log::shouldReceive('debug'); Log::shouldReceive('info'); }
public function testBootClosure() { $tag = ['test-123']; $node = Mockery::mock('C4tech\\Support\\Contracts\\ModelInterface'); $node->parent = Mockery::mock('C4tech\\Support\\Contracts\\ModelInterface[touch]'); $node->parent->shouldReceive('touch')->withNoArgs()->once(); $model = Mockery::mock('stdClass'); $model->shouldReceive('moved')->with(Mockery::on(function ($method) use($node) { expect_not($method($node)); return true; }))->once(); $model->shouldReceive('saved')->with(Mockery::on(function ($method) use($node) { expect_not($method($node)); return true; }))->once(); $model->shouldReceive('deleted')->once(); Config::shouldReceive('get')->with(null, null)->twice()->andReturn($model, null); Config::shouldReceive('get')->with('app.debug')->times(3)->andReturn(true); Log::shouldReceive('info')->with(Mockery::type('string'), Mockery::type('array'))->once(); Log::shouldReceive('debug')->with(Mockery::type('string'), Mockery::type('array'))->twice(); Cache::shouldReceive('tags->flush')->with($tag)->withNoArgs()->once(); $this->repo->shouldReceive('make->getParentTags')->with($node)->withNoArgs()->andReturn($tag); expect_not($this->repo->boot()); }
public function stubUpdate($data = null, $return = true) { Log::shouldReceive('debug')->with(Mockery::type('string'), Mockery::type('array'))->once(); $this->repo->shouldReceive('getModelClass')->withNoArgs()->once()->andReturn('class'); $this->mocked_model->shouldReceive('update')->with($data)->once()->andReturn($return); }
public function testDelete() { $model = 'TestClass'; $instances = ['tag' => 'A TestClass Instance']; $object = Mockery::mock('C4tech\\Support\\Model[delete]')->shouldReceive('delete')->once()->andReturn(true)->getMock(); $object->id = 10; $this->repo->shouldReceive('getModelClass')->withNoArgs()->once()->andReturn($model); Log::shouldReceive('debug')->with(Mockery::type('string'), Mockery::type('array'))->once(); $this->repo->shouldReceive('formatTag')->with($object->id)->once()->andReturn('tag'); $reflection = new ReflectionClass($this->repo); $instance = $reflection->getProperty('object'); $instance->setAccessible(true); $instance->setValue($this->repo, $object); $objects = $reflection->getProperty('instances'); $objects->setAccessible(true); $objects->setValue($this->repo, $instances); expect($this->repo->delete())->true(); expect($objects->getValue($this->repo))->hasntKey('tag'); }