/** * @test */ public function shouldValidatePageSize() { $violation = $this->getMockBuilder(ConstraintViolationBuilderInterface::class)->getMock(); $violation->expects($this->once())->method('setParameters')->with(['%size%' => 100])->willReturnSelf(); $violation->expects($this->once())->method('setInvalidValue')->with(125)->willReturnSelf(); $violation->expects($this->once())->method('setCode')->with(ListQueryParameters::INVALID_PAGE_SIZE)->willReturnSelf(); $violation->expects($this->once())->method('atPath')->with('pageSize')->willReturnSelf(); $violation->expects($this->once())->method('addViolation'); $context = $this->getMockBuilder(ExecutionContextInterface::class)->getMock(); $context->expects($this->once())->method('buildViolation')->with('Page size must be leas or equal than %size%')->willReturn($violation); $query = new ListQueryParameters(); $query->validatePageSize($context); $query->setPageSize(125)->validatePageSize($context); }