/** * Build up an entity and populate it with dummy data. * * @param string $name * @param array $overrides * @return mixed */ public function build($name, $overrides = []) { $attributes = $this->getAttributes($name, $overrides); $class = $this->getFixture($name)->name; // We'll pass off the process of creating the entity. // That way, folks can use different persistence layers. return $this->model->build($class, $attributes); }
function it_can_create_multiple_entities_at_once(IsPersistable $model) { $stub = new AlbumStub(); $model->getAttributes(Argument::any())->willReturn([]); $model->build('Album', Argument::type('array'))->shouldBeCalledTimes(3)->willReturn($stub); $model->save($stub)->shouldBeCalledTimes(3); $collection = $this->setTimes(3)->create('Album'); $collection[0]->shouldEqual($stub); $collection[1]->shouldEqual($stub); $collection[2]->shouldEqual($stub); }