/**
  * Test create() with missing attribute values
  *
  * @return void
  */
 public function testCreateIllegal()
 {
     $accountResource = new Account($this->getMockedClient(new Response(200)));
     self::assertFalse($accountResource->create(new AccountType()));
 }
Exemple #2
0
// get API user info
$logger->log(Logger::INFO, "#################### Getting API user info");
$accountType = $accountResource->getInfo();
foreach ((array) $accountType as $key => $value) {
    $logger->log(Logger::INFO, $key . ': ' . $value);
}
// get all users
$logger->log(Logger::INFO, "#################### Get all users");
$accountTypes = $accountResource->getAll();
foreach ($accountTypes as $accountType) {
    $logger->log(Logger::INFO, $accountType->email);
}
// create random account
$logger->log(Logger::INFO, "#################### Create random account");
$newAccountType = (new AccountType())->fromArray(['email' => uniqid('test-', true) . '@example.com', 'password' => md5(uniqid('t.gif', true)), 'name' => 'Hugh Jazz', 'note' => 'I will not waste chalk', 'storage' => 100000000, 'institution' => 'Duff Beer Inc.']);
$success = $accountResource->create($newAccountType);
if ($success) {
    // get info on specific user
    $logger->log(Logger::INFO, "#################### Get info on specific user");
    $accountType = $accountResource->getByEmail($newAccountType->email);
    foreach ((array) $accountType as $key => $value) {
        if ($value instanceof DateTime) {
            $logger->log(Logger::INFO, $key . ': ' . $value->format(\DateTime::ISO8601));
        } else {
            $logger->log(Logger::INFO, $key . ': ' . $value);
        }
    }
} else {
    $logger->log(Logger::ALERT, 'Could not create account ' . $newAccountType->email);
}
$logger->log(Logger::INFO, "#################### Update account");