public function testUpdateRelationshipsReturnsOptions() { $query = m::mock('Illuminate\\Database\\Eloquent\\Builder'); $queryCollection = m::mock('Illuminate\\Database\\Eloquent\\Collection'); $query->shouldReceive('select')->once()->shouldReceive('get')->once()->andReturn($queryCollection); $relatedModel = m::mock(array('getTable' => 'table', 'getKeyName' => 'id', 'newQuery' => $query)); $model = m::mock(array('field' => m::mock(array('getRelated' => $relatedModel)))); $this->config->shouldReceive('getDataModel')->once()->andReturn($model); $this->db->shouldReceive('raw')->once()->shouldReceive('getTablePrefix')->once(); $field = m::mock('Frozennode\\Administrator\\Fields\\Field'); $field->shouldReceive('getOption')->twice()->andReturn(false, function () { }); $this->factory->shouldReceive('getFieldObjectByName')->once()->andReturn($field)->shouldReceive('applyConstraints')->once()->shouldReceive('filterBySearchTerm')->once()->shouldReceive('formatSelectOptions')->once()->andReturn(array('foo' => 'bar')); $this->assertEquals($this->factory->updateRelationshipOptions('field', 'filter', array(), array(), 'search'), array('foo' => 'bar')); }