credentialsValidator = new CredentialsValidator(); } public function testValidateNoUsername() { $this->expectException('Magento\Framework\Exception\InputException'); $this->expectExceptionMessage('"username" is required. Enter and try again.'); $username = ''; $password = 'my_password'; $this->credentialsValidator->validate($username, $password); } public function testValidateNoPassword() { $this->expectException('Magento\Framework\Exception\InputException'); $this->expectExceptionMessage('"password" is required. Enter and try again.'); $username = 'my_username'; $password = ''; $this->credentialsValidator->validate($username, $password); } public function testValidateValidCredentials() { $username = 'my_username'; $password = 'my_password'; $result = $this->credentialsValidator->validate($username, $password); $this->assertNull($result); } }