function it_should_be_added_new_section(NewSectionListener $listener, AllSurveys $allSurveys, AllSections $allSections) { $organizationId = $this->faker->uuid; $userId = $this->faker->uuid; $surveyId = $this->faker->uuid; $sectionId = new Uuid($this->faker->uuid); $user = new User(new Uuid($userId), $this->faker->name, $this->faker->email); $organization = new Organization(new Uuid($organizationId), $this->faker->name, $user); $survey = new Survey(new Uuid($surveyId), $this->faker->title, $this->faker->text, $organization); $request = new SectionRequest(['title' => $this->faker->title, 'surveyId' => $survey]); $allSurveys->surveyOfId($request->surveyId)->willReturn($survey); $allSections->add(Argument::type(Section::class))->shouldBeCalled(); $allSections->nextIdentity()->willReturn($sectionId); $this->attach($listener); $this->newSection($request); $listener->whenSectionIsAdded(Argument::type(SectionResponse::class))->shouldHaveBeenCalled(); }
function it_should_be_added_new_question(NewQuestionListener $listener, AllInformationFields $allInformationFields, AllSections $allSections, AllQuestions $allQuestions) { $informationFieldId = $this->faker->uuid; $organizationId = $this->faker->uuid; $userId = $this->faker->uuid; $surveyId = $this->faker->uuid; $sectionId = $this->faker->uuid; $questionId = new Uuid($this->faker->uuid); $user = new User(new Uuid($userId), $this->faker->name, $this->faker->email); $organization = new Organization(new Uuid($organizationId), $this->faker->name, $user); $survey = new Survey(new Uuid($surveyId), $this->faker->title, $this->faker->text, $organization); $section = new Section(new Uuid($sectionId), $this->faker->title, $survey); $informationField = new InformationField(new Uuid($informationFieldId), $this->faker->name); $request = new questionRequest(['title' => $this->faker->title, 'weighing' => $this->faker->text, 'informationFieldId' => $informationField, 'sectionId' => $section]); $allInformationFields->informationFieldOfId($request->informationFieldId)->willReturn($informationField); $allSections->sectionOfId($request->sectionId)->willReturn($section); $allQuestions->add(Argument::type(Question::class))->shouldBeCalled(); $allQuestions->nextIdentity()->willReturn($questionId); $this->attach($listener); $this->newQuestion($request); $listener->whenQuestionIsAdded(Argument::type(QuestionResponse::class))->shouldHaveBeenCalled(); }