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(); }