function testLoginCommand() { $username = '******'; $command = new LoginCommand($username); $this->assertEquals(Queries::LOGIN_USER, $command->GetQuery()); $this->assertEquals(1, $command->Parameters->Count()); $par1 = $command->Parameters->Items(0); $this->assertEquals(ParameterNames::USERNAME, $par1->Name); $this->assertEquals(strtolower($username), $par1->Value); }
<?php require_once "command/LoginCommand.php"; require_once "command/CommandContext.php"; $context = new CommandContext(); $context->addParam("username", "bob"); $context->addParam("pass", "tiddles"); $cmd = new LoginCommand(new AccessManager()); if (!$cmd->execute($context)) { print "an error occurred: " . $context->getError(); } else { print "successful login\n"; $user_obj = $context->get("user"); }