function it_should_be_added_new_information_field(NewInformationFieldListener $listener, AllInformationFields $allInformationFields) { $informationFieldId = new Uuid($this->faker->uuid); $request = new InformationFieldRequest(['name' => $this->faker->name]); $allInformationFields->add(Argument::type(InformationField::class))->shouldBeCalled(); $allInformationFields->nextIdentity()->willReturn($informationFieldId); $this->attach($listener); $this->newInformationField($request); $listener->whenInformationFieldIsAdded(Argument::type(InformationFieldResponse::class))->shouldHaveBeenCalled(); }
/** * @param InformationFieldRequest $request */ public function newInformationField(InformationFieldRequest $request) { $informationField = new InformationField($this->allInformationFields->nextIdentity(), $request->name); $this->allInformationFields->add($informationField); $this->informationFieldListener->whenInformationFieldIsAdded(new InformationFieldResponse($informationField)); }