ticketGateway = $this->createMock(TicketGateway::class); $this->ticketValidator = new TicketValidators($this->ticketGateway); } function testItReturnsTrueWhenTheUserIsMaxedOutOnOpenTickets() { //-- Arrange $tickets = [new Ticket(), new Ticket(), new Ticket()]; $this->ticketGateway->method('getTicketsByEmail') ->with('my@email.com') ->willReturn($tickets); $heskSettings = array( 'max_open' => 3 ); //-- Act $result = $this->ticketValidator->isCustomerAtMaxTickets('my@email.com', $heskSettings); //-- Assert $this->assertThat($result, $this->isTrue(), str_replace('test','',__FUNCTION__)); } function testItReturnsFalseWhenTheUserIsNotMaxedOutOnOpenTickets() { //-- Arrange $tickets = [new Ticket(), new Ticket(), new Ticket()]; $this->ticketGateway->method('getTicketsByEmail') ->with('my@email.com') ->willReturn($tickets); $heskSettings = array( 'max_open' => 10 ); //-- Act $result = $this->ticketValidator->isCustomerAtMaxTickets('my@email.com', $heskSettings); //-- Assert $this->assertThat($result, $this->isFalse(), str_replace('test','',__FUNCTION__)); } function testItReturnsFalseWhenMaxOpenIsZero() { //-- Arrange $tickets = [new Ticket(), new Ticket(), new Ticket()]; $this->ticketGateway->method('getTicketsByEmail') ->with('my@email.com') ->willReturn($tickets); $heskSettings = array( 'max_open' => 0 ); //-- Act $result = $this->ticketValidator->isCustomerAtMaxTickets('my@email.com', $heskSettings); //-- Assert $this->assertThat($result, $this->isFalse(), str_replace('test','',__FUNCTION__)); } }