/** * Test getAll() * * @return void */ public function testGetAll() { $accountResource = new Account($this->getMockedClient(new Response(200, ['Content-Type' => 'application/json'], file_get_contents(__DIR__ . '/../../assets/AccountTest_getAll.json')))); $libs = $accountResource->getAll(); self::assertInternalType('array', $libs); foreach ($libs as $lib) { self::assertInstanceOf('Seafile\\Client\\Type\\Account', $lib); } }
if (!is_readable($cfgFile)) { throw new Exception($cfgFile . ' is not readable or does not exist.'); } $token = json_decode(file_get_contents($tokenFile)); $cfg = json_decode(file_get_contents($cfgFile)); $client = new Client(['base_uri' => $cfg->baseUri, 'debug' => true, 'handler' => $stack, 'headers' => ['Content-Type' => 'application/json', 'Authorization' => 'Token ' . $token->token]]); $accountResource = new Account($client); // 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 {