userContextMock = $this->createMock(UserContextInterface::class); $this->sessionMock = $this->createMock(Session::class); $this->customerRepositoryMock = $this->createMock(CustomerRepository::class); $this->addUserInfoToContextMock = $this->createMock(AddUserInfoToContext::class); $this->graphQlMock = $this->createMock(GraphQl::class); $this->responseMock = $this->createMock(ResponseInterface::class); $this->customerMock = $this->createMock(CustomerInterface::class); $this->clearCustomerSessionAfterRequest = new ClearCustomerSessionAfterRequest( $this->userContextMock, $this->sessionMock, $this->customerRepositoryMock, $this->addUserInfoToContextMock ); } /** * Test after dispatch plugin */ public function testAfterDispatch(): void { $this->addUserInfoToContextMock ->expects($this->once()) ->method('getLoggedInCustomerData'); $this->clearCustomerSessionAfterRequest->afterDispatch($this->graphQlMock, $this->responseMock); } /** * Test after dispatch plugin for logged in customer */ public function testAfterDispatchForLoggedInCustomer(): void { $this->addUserInfoToContextMock ->expects($this->once()) ->method('getLoggedInCustomerData') ->willReturn($this->customerMock); $this->customerMock ->expects($this->once()) ->method('getId'); $this->customerMock ->expects($this->once()) ->method('getGroupId'); $this->clearCustomerSessionAfterRequest->afterDispatch($this->graphQlMock, $this->responseMock); } protected function tearDown(): void { unset( $this->clearCustomerSessionAfterRequest, $this->userContextMock, $this->sessionMock, $this->customerRepositoryMock, $this->addUserInfoToContextMock, $this->graphQlMock, $this->responseMock, $this->customerMock ); } }