/**
  * @test
  */
 public function shouldFailToEditUserWhenNoDataIsSupplied()
 {
     $this->setExpectedException(NothingToModifyException::class);
     $handler = HandlerStack::create();
     $this->client = ProvisioningClientCreator::createProvisioningClient($handler);
     $editUserCommand = new EditUser('username');
     $this->client->editUser($editUserCommand);
 }
 /**
  * @test
  */
 public function shouldFailToGetUserWhenInvalidDataIsSupplied()
 {
     $mock = new MockHandler([new Response(200, [], '<?xml version="1.0"?><ocs><meta><statuscode>101</statuscode><status>ok</status></meta></ocs>')]);
     $handler = HandlerStack::create($mock);
     $this->client = ProvisioningClientCreator::createProvisioningClient($handler);
     $findGroupOfUser = new FindGroupsOfUser('frank');
     $findUsersResult = $this->client->findGroupOfUsers($findGroupOfUser);
     $this->assertEquals(101, $findUsersResult->statusCode);
 }
 /**
  * @test
  */
 public function shouldFailToGetUserWhenInvalidDataIsSupplied()
 {
     $mock = new MockHandler([new Response(200, [], '<?xml version="1.0"?><ocs><meta><statuscode>101</statuscode><status>ok</status></meta></ocs>')]);
     $handler = HandlerStack::create($mock);
     $this->client = ProvisioningClientCreator::createProvisioningClient($handler);
     $getUserCommand = new FindUser('username');
     /** @var User $getUserResult */
     $getUserResult = $this->client->findUser($getUserCommand);
     $this->assertInstanceOf(User::class, $getUserResult);
     $this->assertEquals(101, $getUserResult->statusCode);
 }
예제 #4
0
<?php

/**
 * This script just fills up the table oc_uc_storageusage for some basic testing
 */
use Arnovr\OwncloudProvisioning\ApiConnection;
use Arnovr\OwncloudProvisioning\ProvisioningClient;
use Arnovr\OwncloudProvisioning\ResponseParser\XMLResponseParser;
use GuzzleHttp\Client;
include '/var/www/owncloud/config/config.php';
include '../vendor/autoload.php';
$provisioningClient = new ProvisioningClient(new ApiConnection(new Client(), 'http://localhost/ocs/v1.php/cloud', 'admin', 'admin', 5), new XMLResponseParser());
$connect = mysqli_connect('localhost', $CONFIG['dbuser'], $CONFIG['dbpassword'], 'owncloud');
$result = mysqli_query($connect, "select username from oc_uc_storageusage GROUP by username");
while ($row = $result->fetch_assoc()) {
    $provisioningClient->createUser(new \Arnovr\OwncloudProvisioning\Command\CreateUser($row['username'], 'password'));
    echo "Added " . $row['username'] . " \n";
}