From 80031811969c8e16ed4e68e3f9d39b167b6f9f5d Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Fri, 26 Jun 2020 18:45:54 +0200 Subject: [PATCH 01/21] [NS] First Commit --- composer.json | 7 +- docs/Bitbucket/Api/Workspaces.html | 1026 +++++++++++++++++ docs/Bitbucket/Api/WorkspacesOld.html | 310 +++++ src/Api/AbstractApi.php | 9 +- src/Api/Repositories.php | 11 + src/Api/Repositories/Workspaces.php | 81 ++ .../Workspaces/AbstractWorkspacesApi.php | 45 + .../Repositories/Workspaces/Repositories.php | 52 + src/Api/Teams/Projects.php | 41 +- src/Api/Teams/Repositories.php | 22 +- src/Api/Workspaces.php | 45 + src/Client.php | 9 + tests/CreatesApplication.php | 18 + tests/TestCase.php | 18 + tests/WorkspacesTest.php | 37 + tests/responses/WorkspacesListResponse.php | 277 +++++ tests/stubs/workspaces-list-success.json | 177 +++ 17 files changed, 2175 insertions(+), 10 deletions(-) create mode 100644 docs/Bitbucket/Api/Workspaces.html create mode 100644 docs/Bitbucket/Api/WorkspacesOld.html create mode 100644 src/Api/Repositories/Workspaces.php create mode 100644 src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php create mode 100644 src/Api/Repositories/Workspaces/Repositories.php create mode 100644 src/Api/Workspaces.php create mode 100644 tests/CreatesApplication.php create mode 100644 tests/TestCase.php create mode 100644 tests/WorkspacesTest.php create mode 100644 tests/responses/WorkspacesListResponse.php create mode 100644 tests/stubs/workspaces-list-success.json diff --git a/composer.json b/composer.json index 937a424..d2b09de 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,14 @@ "php-http/cache-plugin": "^1.6", "php-http/client-implementation": "^1.0", "php-http/client-common": "^1.9|^2.0", - "php-http/multipart-stream-builder": "^1.0" + "illuminate/support": "^5.8|^6.0", + "php-http/multipart-stream-builder": "^1.0", + "php-http/mock-client": "^1.3" }, "require-dev": { "graham-campbell/analyzer": "^2.4", - "phpunit/phpunit": "^7.5|^8.5|^9.0", + "phpunit/phpunit": "^7.5|^8.5", + "orchestra/testbench": "^3.1|^4.0", "php-http/guzzle6-adapter": "^1.1|^2.0" }, "autoload": { diff --git a/docs/Bitbucket/Api/Workspaces.html b/docs/Bitbucket/Api/Workspaces.html new file mode 100644 index 0000000..0c755b8 --- /dev/null +++ b/docs/Bitbucket/Api/Workspaces.html @@ -0,0 +1,1026 @@ + + + + + + Bitbucket\Api\Workspaces | Bitbucket API Client + + + + + + + + + + + + + + + + +
+
+
+ +
+ + +
+
+ +
+ +
+
+ + +
+ +
+
+ + + +

class + Workspaces extends AbstractApi (View source) +

+ + + + +
+

The Workspaces api class.

+ + + + +

Methods

+ +
+
+
+ void +
+
+ __construct(HttpMethodsClient $client) + +

Create a new api instance.

+ +
+
+
+ int|null +
+
+ getPerPage() + +

Get the number of values to fetch per page.

+ +
+
+
+ void +
+
+ setPerPage(int $perPage = null) + +

Set the number of values to fetch per page.

+ +
+
+
+ HttpMethodsClient +
+
+ getHttpClient() + +

Get the http methods client.

+ +
+
+
+ array +
+
+ get(string $path, array $params = [], array $headers = []) + +

Send a GET request with query params.

+ +
+
+
+ ResponseInterface +
+
+ pureGet(string $path, array $params = [], array $headers = []) + +

Send a GET request with query params.

+ +
+
+
+ array +
+
+ post(string $path, array $params = [], array $headers = []) + +

Send a POST request with JSON-encoded params.

+ +
+
+
+ array +
+
+ postRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) + +

Send a POST request with raw data.

+ +
+
+
+ array +
+
+ put(string $path, array $params = [], array $headers = []) + +

Send a PUT request with JSON-encoded params.

+ +
+
+
+ array +
+
+ putRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) + +

Send a PUT request with raw data.

+ +
+
+
+ array +
+
+ delete(string $path, array $params = [], array $headers = []) + +

Send a DELETE request with JSON-encoded params.

+ +
+
+
+ array +
+
+ deleteRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) + +

Send a DELETE request with raw data.

+ +
+
+
+ static string +
+
+ buildPath(string ...$parts) + +

Build a URL path from the given parts.

+ +
+
+
+ array +
+
+ list(array $params = []) + +

No description

+
+
+
+
+
+ string +
+
+ buildWorkspacesPath(string ...$parts) + +

Build the workspaces path from the given parts.

+
+
+
+ + +

Details

+ +
+
+

+ + void + __construct(HttpMethodsClient $client) + +

+
+ + + +
+

Create a new api instance.

+
+

Parameters

+ + + + + + + +
HttpMethodsClient$client
+ + +

Return Value

+ + + + + + +
void
+ + + +
+
+ +
+
+

+ + int|null + getPerPage() + +

+
+ + + +
+

Get the number of values to fetch per page.

+
+ +

Return Value

+ + + + + + +
int|null
+ + + +
+
+ +
+
+

+ + void + setPerPage(int $perPage = null) + +

+
+ + + +
+

Set the number of values to fetch per page.

+
+

Parameters

+ + + + + + + +
int$perPage
+ + +

Return Value

+ + + + + + +
void
+ + + +
+
+ +
+
+

+ + protected HttpMethodsClient + getHttpClient() + +

+
+ + + +
+

Get the http methods client.

+
+ +

Return Value

+ + + + + + +
HttpMethodsClient
+ + + +
+
+ +
+
+

+ + protected array + get(string $path, array $params = [], array $headers = []) + +

+
+ + + +
+

Send a GET request with query params.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
array$params
array$headers
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + protected ResponseInterface + pureGet(string $path, array $params = [], array $headers = []) + +

+
+ + + +
+

Send a GET request with query params.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
array$params
array$headers
+ + +

Return Value

+ + + + + + +
ResponseInterface
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + protected array + post(string $path, array $params = [], array $headers = []) + +

+
+ + + +
+

Send a POST request with JSON-encoded params.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
array$params
array$headers
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + protected array + postRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) + +

+
+ + + +
+

Send a POST request with raw data.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
string|StreamInterface|null$body
array$headers
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + protected array + put(string $path, array $params = [], array $headers = []) + +

+
+ + + +
+

Send a PUT request with JSON-encoded params.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
array$params
array$headers
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + protected array + putRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) + +

+
+ + + +
+

Send a PUT request with raw data.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
string|StreamInterface|null$body
array$headers
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + protected array + delete(string $path, array $params = [], array $headers = []) + +

+
+ + + +
+

Send a DELETE request with JSON-encoded params.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
array$params
array$headers
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + protected array + deleteRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) + +

+
+ + + +
+

Send a DELETE request with raw data.

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
string$path
string|StreamInterface|null$body
array$headers
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+

+ + static protected string + buildPath(string ...$parts) + +

+
+ + + +
+

Build a URL path from the given parts.

+
+

Parameters

+ + + + + + + +
string...$parts
+ + +

Return Value

+ + + + + + +
string
+ + +

Exceptions

+ + + + + + +
InvalidArgumentException
+ + +
+
+ +
+
+

+ + array + list(array $params = []) + +

+
+ + + +
+

Parameters

+ + + + + + + +
array$params
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+
+ +
+
+

+ + protected string + buildWorkspacesPath(string ...$parts) + +

+
+ + + +
+

Build the workspaces path from the given parts.

+
+

Parameters

+ + + + + + + +
string...$parts
+ + +

Return Value

+ + + + + + +
string
+ + +

Exceptions

+ + + + + + +
InvalidArgumentException
+ + +
+
+ +
+
+ + +
+ + +
+
+ + + diff --git a/docs/Bitbucket/Api/WorkspacesOld.html b/docs/Bitbucket/Api/WorkspacesOld.html new file mode 100644 index 0000000..85190b1 --- /dev/null +++ b/docs/Bitbucket/Api/WorkspacesOld.html @@ -0,0 +1,310 @@ + + + + + + Bitbucket\Api\Repositories | Bitbucket API Client + + + + + + + + + + + + + + + + +
+
+
+ +
+ + +
+
+ +
+ +
+
+ + +
+ +
+
+ + + +

class + Workspaces extends AbstractApi (View source) +

+ + + + +
+

The workspaces api class.

+ + + + +

Methods

+ +
+
+
+ void +
+
+ __construct(HttpMethodsClient $client) + +

Create a new api instance.

+ +
+
+
+ int|null +
+
+ getPerPage() + +

Get the number of values to fetch per page.

+ +
+
+
+ void +
+
+ setPerPage(int $perPage = null) + +

Set the number of values to fetch per page.

+ +
+
+
+ array +
+
+ list(array $params = []) + +

No description

+
+
+
+ +

Details

+ +
+
+

+ + void + __construct(HttpMethodsClient $client) + +

+
+ + + +
+

Create a new api instance.

+
+

Parameters

+ + + + + + + +
HttpMethodsClient$client
+ + +

Return Value

+ + + + + + +
void
+ + + +
+
+ +
+
+

+ + int|null + getPerPage() + +

+
+ + + +
+

Get the number of values to fetch per page.

+
+ +

Return Value

+ + + + + + +
int|null
+ + + +
+
+ +
+
+

+ + void + setPerPage(int $perPage = null) + +

+
+ + + +
+

Set the number of values to fetch per page.

+
+

Parameters

+ + + + + + + +
int$perPage
+ + +

Return Value

+ + + + + + +
void
+ + + +
+
+ +
+
+

+ + array + list(array $params = []) + +

+
+ + + +
+

Parameters

+ + + + + + + +
array$params
+ + +

Return Value

+ + + + + + +
array
+ + +

Exceptions

+ + + + + + +
Exception
+ + +
+
+ +
+ + +
+ + +
+
+ + + diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 10cd938..050eb45 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -105,6 +105,8 @@ protected function get(string $path, array $params = [], array $headers = []) { $response = $this->pureGet($path, $params, $headers); + dd($response); + return ResponseMediator::getContent($response); } @@ -136,12 +138,11 @@ protected function pureGet(string $path, array $params = [], array $headers = [] * Send a POST request with JSON-encoded params. * * @param string $path - * @param array $params - * @param array $headers - * - * @throws \Http\Client\Exception + * @param array $params + * @param array $headers * * @return array + * @throws \Http\Client\Exception */ protected function post(string $path, array $params = [], array $headers = []) { diff --git a/src/Api/Repositories.php b/src/Api/Repositories.php index 70e6679..5b01a8e 100644 --- a/src/Api/Repositories.php +++ b/src/Api/Repositories.php @@ -14,6 +14,7 @@ namespace Bitbucket\Api; use Bitbucket\Api\Repositories\Users as RepositoriesUsers; +use Bitbucket\Api\Repositories\Workspaces as RepositoriesWorkspaces; /** * The repositories api class. @@ -46,6 +47,16 @@ public function users(string $username) return new RepositoriesUsers($this->getHttpClient(), $username); } + /** + * @param string $username + * + * @return \Bitbucket\Api\Repositories\Workspaces + */ + public function workspaces(string $username) + { + return new RepositoriesWorkspaces($this->getHttpClient(), $username); + } + /** * Build the repositories path from the given parts. * diff --git a/src/Api/Repositories/Workspaces.php b/src/Api/Repositories/Workspaces.php new file mode 100644 index 0000000..c992dfe --- /dev/null +++ b/src/Api/Repositories/Workspaces.php @@ -0,0 +1,81 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\Api\Repositories; + +use Bitbucket\Api\Repositories\Workspaces\Repositories; + +/** + * The users api class. + * + * @author Graham Campbell + */ +class Workspaces extends AbstractRepositoriesApi +{ + /** + * @param string $repo + * + * @return \Bitbucket\Api\Repositories\Workspaces\Repositories + */ + public function repositories(string $repo) + { + return new Repositories($this->getHttpClient(), $this->username, $repo); + } + + /** + * @param string $repo + * @param $scm + * @param $project_key + * @param $is_private + * + * @return array + * + * @throws \Http\Client\Exception + */ + public function createRepository(string $repo, $scm, $project_key, $is_private) + { + $params = [ + 'scm' => $scm, + 'project' => (object)[ + 'key' => $project_key + ], + 'is_private' => $is_private + ]; + + $path = $this->buildRepositoriesPath($repo).static::URI_SEPARATOR; + + return $this->post($path, $params); + } + + /** + * @param string $repo + * @param array $params + * @return array + * @throws \Http\Client\Exception + */ + public function showRepositories(string $repo, array $params = []) + { + $path = $this->buildRepositoriesPath($repo); + + return $this->get($path, $params); + } + + /** + * @param string ...$parts + * @return string + */ + protected function buildRepositoriesPath(string ...$parts) + { + return static::buildPath('repositories', $this->username, ...$parts); + } +} diff --git a/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php new file mode 100644 index 0000000..ae4e14f --- /dev/null +++ b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\Api\Repositories\Workspaces; + +use Bitbucket\Api\Repositories\AbstractRepositoriesApi; +use Http\Client\Common\HttpMethodsClient; + +/** + * The abstract users api class. + * + * @author Graham Campbell + */ +abstract class AbstractWorkspacesApi extends AbstractRepositoriesApi +{ + /** + * The repo. + * + * @var string + */ + protected $repo; + + /** + * Create a new api instance. + * + * @param \Http\Client\Common\HttpMethodsClient $client + * @param string $username + * @param string $repo + */ + public function __construct(HttpMethodsClient $client, string $username, string $repo) + { + parent::__construct($client, $username); + $this->repo = $repo; + } +} diff --git a/src/Api/Repositories/Workspaces/Repositories.php b/src/Api/Repositories/Workspaces/Repositories.php new file mode 100644 index 0000000..24feb11 --- /dev/null +++ b/src/Api/Repositories/Workspaces/Repositories.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\Api\Repositories\Workspaces; + +/** + * The users api class. + * + * @author Graham Campbell + */ +class Repositories extends AbstractWorkspacesApi +{ + + /** + * @param string $repo + * @param array $params + * + * @throws \Http\Client\Exception + * + * @return array + */ + public function show(string $repo, array $params = []) + { + $path = $this->buildRepositoryPath($repo); + + return $this->get($path, $params); + } + + /** + * Build the commit path from the given parts. + * + * @param string[] $parts + * + * @throws \Bitbucket\Exception\InvalidArgumentException + * + * @return string + */ + protected function buildRepositoryPath(string ...$parts) + { + return static::buildPath('repositories', $this->username, ...$parts); + } +} \ No newline at end of file diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index 1a32d92..0354443 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -35,14 +35,49 @@ public function list(array $params = []) } /** - * @param array $params * * @throws \Http\Client\Exception * * @return array */ - public function create(array $params = []) + public function all() + { + $projects = []; + $page = 1; + + do { + $project = $this->list(['page' => $page]); + $projects = array_merge($projects, $project['values']); + $page++; + } while (isset($project['next'])); + + return $projects; + } + + /** + * @param string $name + * @param string $key + * @param string $description + * @param string $links + * @param bool $is_private + * + * @return array + * @throws \Http\Client\Exception + */ + public function create(string $name, string $key, string $description, string $links, bool $is_private) { + $params = [ + 'name' => $name, + 'key' => $key, + 'description' => $description, + 'links' => (object)[ + 'avatar' => (object)[ + 'href' => $links + ] + ], + 'is_private' => $is_private + ]; + $path = $this->buildProjectsPath().static::URI_SEPARATOR; return $this->post($path, $params); @@ -104,6 +139,6 @@ public function remove(string $project, array $params = []) */ protected function buildProjectsPath(string ...$parts) { - return static::buildPath('teams', $this->username, 'projects', ...$parts); + return static::buildPath('workspaces', $this->username, 'projects', ...$parts); } } diff --git a/src/Api/Teams/Repositories.php b/src/Api/Teams/Repositories.php index 59e823a..b29f05e 100644 --- a/src/Api/Teams/Repositories.php +++ b/src/Api/Teams/Repositories.php @@ -34,6 +34,26 @@ public function list(array $params = []) return $this->get($path, $params); } + /** + * + * @throws \Http\Client\Exception + * + * @return array + */ + public function all() + { + $repos = []; + $page = 1; + + do { + $repo = $this->list(['page' => $page]); + $repos = array_merge($repos, $repo['values']); + $page++; + } while (isset($repo['next'])); + + return $repos; + } + /** * Build the repositories path from the given parts. * @@ -45,6 +65,6 @@ public function list(array $params = []) */ protected function buildRepositoriesPath(string ...$parts) { - return static::buildPath('teams', $this->username, 'repositories', ...$parts); + return static::buildPath('repositories', $this->username); } } diff --git a/src/Api/Workspaces.php b/src/Api/Workspaces.php new file mode 100644 index 0000000..5bfc989 --- /dev/null +++ b/src/Api/Workspaces.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Bitbucket\Api; + +class Workspaces extends AbstractApi +{ + /** + * @param array $params + * + * @throws \Http\Client\Exception + * + * @return array + */ + public function list(array $params = []) + { + $path = $this->buildWorkspacePath(); + + return $this->get($path, $params); + } + + /** + * Build the workspaces path from the given parts. + * + * @param string[] $parts + * + * @throws \Bitbucket\Exception\InvalidArgumentException + * + * @return string + */ + protected function buildWorkspacePath(string ...$parts) + { + return static::buildPath('workspaces', ...$parts); + } +} \ No newline at end of file diff --git a/src/Client.php b/src/Client.php index 8072454..71926fe 100644 --- a/src/Client.php +++ b/src/Client.php @@ -21,6 +21,7 @@ use Bitbucket\Api\Snippets; use Bitbucket\Api\Teams; use Bitbucket\Api\Users; +use Bitbucket\Api\Workspaces; use Bitbucket\HttpClient\Builder; use Bitbucket\HttpClient\Plugin\Authentication; use Bitbucket\HttpClient\Plugin\ExceptionThrower; @@ -131,6 +132,14 @@ public function repositories() return new Repositories($this->getHttpClient()); } + /** + * @return \Bitbucket\Api\Workspaces + */ + public function workspaces() + { + return new Workspaces($this->getHttpClient()); + } + /** * @return \Bitbucket\Api\Snippets */ diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php new file mode 100644 index 0000000..cda78c4 --- /dev/null +++ b/tests/CreatesApplication.php @@ -0,0 +1,18 @@ +packagePath('/tests/stubs/workspaces-list-success.json'); + + $mock_client = new MockClient; + + $response = $this->createMock('Bitbucket\Tests\responses\WorkspacesListResponse'); + + $mock_client->setDefaultResponse($response); + + $request = $this->createMock('Psr\Http\Message\RequestInterface'); + + $response = $mock_client->sendRequest($request); + + + + dd($response->getStatusCode()); + + /*$builder = new Builder($mock_client); + + $client = new Client($builder);*/ + } +} diff --git a/tests/responses/WorkspacesListResponse.php b/tests/responses/WorkspacesListResponse.php new file mode 100644 index 0000000..42ba744 --- /dev/null +++ b/tests/responses/WorkspacesListResponse.php @@ -0,0 +1,277 @@ +getHeaders() as $name => $values) { + * echo $name . ": " . implode(", ", $values); + * } + * + * // Emit headers iteratively: + * foreach ($message->getHeaders() as $name => $values) { + * foreach ($values as $value) { + * header(sprintf('%s: %s', $name, $value), false); + * } + * } + * + * While header names are not case-sensitive, getHeaders() will preserve the + * exact case in which headers were originally specified. + * + * @return string[][] Returns an associative array of the message's headers. Each + * key MUST be a header name, and each value MUST be an array of strings + * for that header. + */ + public function getHeaders() + { + // TODO: Implement getHeaders() method. + } + + /** + * Checks if a header exists by the given case-insensitive name. + * + * @param string $name Case-insensitive header field name. + * @return bool Returns true if any header names match the given header + * name using a case-insensitive string comparison. Returns false if + * no matching header name is found in the message. + */ + public function hasHeader($name) + { + // TODO: Implement hasHeader() method. + } + + /** + * Retrieves a message header value by the given case-insensitive name. + * + * This method returns an array of all the header values of the given + * case-insensitive header name. + * + * If the header does not appear in the message, this method MUST return an + * empty array. + * + * @param string $name Case-insensitive header field name. + * @return string[] An array of string values as provided for the given + * header. If the header does not appear in the message, this method MUST + * return an empty array. + */ + public function getHeader($name) + { + // TODO: Implement getHeader() method. + } + + /** + * Retrieves a comma-separated string of the values for a single header. + * + * This method returns all of the header values of the given + * case-insensitive header name as a string concatenated together using + * a comma. + * + * NOTE: Not all header values may be appropriately represented using + * comma concatenation. For such headers, use getHeader() instead + * and supply your own delimiter when concatenating. + * + * If the header does not appear in the message, this method MUST return + * an empty string. + * + * @param string $name Case-insensitive header field name. + * @return string A string of values as provided for the given header + * concatenated together using a comma. If the header does not appear in + * the message, this method MUST return an empty string. + */ + public function getHeaderLine($name) + { + // TODO: Implement getHeaderLine() method. + } + + /** + * Return an instance with the provided value replacing the specified header. + * + * While header names are case-insensitive, the casing of the header will + * be preserved by this function, and returned from getHeaders(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new and/or updated header and value. + * + * @param string $name Case-insensitive header field name. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withHeader($name, $value) + { + // TODO: Implement withHeader() method. + } + + /** + * Return an instance with the specified header appended with the given value. + * + * Existing values for the specified header will be maintained. The new + * value(s) will be appended to the existing list. If the header did not + * exist previously, it will be added. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new header and/or value. + * + * @param string $name Case-insensitive header field name to add. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withAddedHeader($name, $value) + { + // TODO: Implement withAddedHeader() method. + } + + /** + * Return an instance without the specified header. + * + * Header resolution MUST be done without case-sensitivity. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the named header. + * + * @param string $name Case-insensitive header field name to remove. + * @return static + */ + public function withoutHeader($name) + { + // TODO: Implement withoutHeader() method. + } + + /** + * Gets the body of the message. + * + * @return StreamInterface Returns the body as a stream. + */ + public function getBody() + { + // TODO: Implement getBody() method. + } + + /** + * Return an instance with the specified message body. + * + * The body MUST be a StreamInterface object. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return a new instance that has the + * new body stream. + * + * @param StreamInterface $body Body. + * @return static + * @throws \InvalidArgumentException When the body is not valid. + */ + public function withBody(StreamInterface $body) + { + return Stream::factory($this->packagePath('/tests/stubs/workspaces-list-success.json')); + } + + /** + * Gets the response status code. + * + * The status code is a 3-digit integer result code of the server's attempt + * to understand and satisfy the request. + * + * @return int Status code. + */ + public function getStatusCode() + { + return 200; + } + + /** + * Return an instance with the specified status code and, optionally, reason phrase. + * + * If no reason phrase is specified, implementations MAY choose to default + * to the RFC 7231 or IANA recommended reason phrase for the response's + * status code. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated status and reason phrase. + * + * @link http://tools.ietf.org/html/rfc7231#section-6 + * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml + * @param int $code The 3-digit integer result code to set. + * @param string $reasonPhrase The reason phrase to use with the + * provided status code; if none is provided, implementations MAY + * use the defaults as suggested in the HTTP specification. + * @return static + * @throws \InvalidArgumentException For invalid status code arguments. + */ + public function withStatus($code, $reasonPhrase = '') + { + // TODO: Implement withStatus() method. + } + + /** + * Gets the response reason phrase associated with the status code. + * + * Because a reason phrase is not a required element in a response + * status line, the reason phrase value MAY be null. Implementations MAY + * choose to return the default RFC 7231 recommended reason phrase (or those + * listed in the IANA HTTP Status Code Registry) for the response's + * status code. + * + * @link http://tools.ietf.org/html/rfc7231#section-6 + * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml + * @return string Reason phrase; must return an empty string if none present. + */ + public function getReasonPhrase() + { + // TODO: Implement getReasonPhrase() method. + } + + protected function packagePath($path) + { + return __DIR__.'/../'.$path; + } +} \ No newline at end of file diff --git a/tests/stubs/workspaces-list-success.json b/tests/stubs/workspaces-list-success.json new file mode 100644 index 0000000..0098f8f --- /dev/null +++ b/tests/stubs/workspaces-list-success.json @@ -0,0 +1,177 @@ +{ + "pagelen":10, + "values":[ + { + "uuid":"{0584df52-5266-40ae-b72e-b72658b09f50}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/giacomo92" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/giacomo92" + }, + "html":{ + "href":"https://bitbucket.org/giacomo92/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/giacomo92/avatar/?ts=1543645840" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92/projects" + } + }, + "created_on":"2018-12-01T06:30:40.906876+00:00", + "type":"workspace", + "slug":"giacomo92", + "is_private":true, + "name":"Giacomo Fabbian" + }, + { + "uuid":"{36c4305a-34ad-4853-967f-bca30aeeba81}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/appizza/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/appizza" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/appizza" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/appizza" + }, + "html":{ + "href":"https://bitbucket.org/appizza/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/appizza/avatar/?ts=1543645840" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/appizza/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/appizza/projects" + } + }, + "created_on":"2018-12-01T06:30:40.921862+00:00", + "type":"workspace", + "slug":"appizza", + "is_private":false, + "name":"Appizza" + }, + { + "uuid":"{b5d5d71e-49d3-4917-9390-b88e25ecb2a6}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/matteogiacomo" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/matteogiacomo" + }, + "html":{ + "href":"https://bitbucket.org/matteogiacomo/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/matteogiacomo/avatar/?ts=1543668122" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo/projects" + } + }, + "created_on":"2018-12-01T12:42:02.071886+00:00", + "type":"workspace", + "slug":"matteogiacomo", + "is_private":false, + "name":"matteogiacomo" + }, + { + "uuid":"{5b98396b-d55e-44ae-8559-46b55559ebe2}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/jack_0/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/jack_0" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/jack_0" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/jack_0" + }, + "html":{ + "href":"https://bitbucket.org/jack_0/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/jack_0/avatar/?ts=1543675270" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/jack_0/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/jack_0/projects" + } + }, + "created_on":"2018-12-01T14:41:10.784154+00:00", + "type":"workspace", + "slug":"jack_0", + "is_private":false, + "name":"jack_0" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/offlineagency" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/offlineagency" + }, + "html":{ + "href":"https://bitbucket.org/offlineagency/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/offlineagency/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"offlineagency", + "is_private":false, + "name":"offline-agency" + } + ], + "page":1, + "size":5 +} From 88f0461767f52ec2bf18b3d14073fda4882c17a2 Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 08:26:35 +0200 Subject: [PATCH 02/21] [GF] Setup tests --- composer.json | 4 +- src/Api/AbstractApi.php | 2 - src/Api/Teams/Projects.php | 14 +- tests/ProjectsTest.php | 42 ++++ tests/TestCase.php | 15 +- tests/WorkspacesTest.php | 45 ++-- tests/responses/BaseResponse.php | 26 ++ tests/responses/WorkspacesListResponse.php | 279 +-------------------- tests/stubs/workspaces-list-success.json | 100 ++++---- 9 files changed, 175 insertions(+), 352 deletions(-) create mode 100644 tests/ProjectsTest.php create mode 100644 tests/responses/BaseResponse.php diff --git a/composer.json b/composer.json index d2b09de..f596546 100644 --- a/composer.json +++ b/composer.json @@ -24,9 +24,9 @@ }, "require-dev": { "graham-campbell/analyzer": "^2.4", - "phpunit/phpunit": "^7.5|^8.5", "orchestra/testbench": "^3.1|^4.0", - "php-http/guzzle6-adapter": "^1.1|^2.0" + "php-http/guzzle6-adapter": "^1.1|^2.0", + "phpunit/phpunit": "^9.2" }, "autoload": { "psr-4": { diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 050eb45..844e45f 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -105,8 +105,6 @@ protected function get(string $path, array $params = [], array $headers = []) { $response = $this->pureGet($path, $params, $headers); - dd($response); - return ResponseMediator::getContent($response); } diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index 0354443..64e2375 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -13,6 +13,8 @@ namespace Bitbucket\Api\Teams; +use Http\Client\Exception; + /** * The projects api class. * @@ -23,7 +25,7 @@ class Projects extends AbstractTeamsApi /** * @param array $params * - * @throws \Http\Client\Exception + * @throws Exception * * @return array */ @@ -36,7 +38,7 @@ public function list(array $params = []) /** * - * @throws \Http\Client\Exception + * @throws Exception * * @return array */ @@ -62,7 +64,7 @@ public function all() * @param bool $is_private * * @return array - * @throws \Http\Client\Exception + * @throws Exception */ public function create(string $name, string $key, string $description, string $links, bool $is_private) { @@ -87,7 +89,7 @@ public function create(string $name, string $key, string $description, string $l * @param string $project * @param array $params * - * @throws \Http\Client\Exception + * @throws Exception * * @return array */ @@ -102,7 +104,7 @@ public function show(string $project, array $params = []) * @param string $project * @param array $params * - * @throws \Http\Client\Exception + * @throws Exception * * @return array */ @@ -117,7 +119,7 @@ public function update(string $project, array $params = []) * @param string $project * @param array $params * - * @throws \Http\Client\Exception + * @throws Exception * * @return array */ diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php new file mode 100644 index 0000000..1f06cb9 --- /dev/null +++ b/tests/ProjectsTest.php @@ -0,0 +1,42 @@ +getClient($response); + $projects = $client->teams('test')->projects()->all(); + + $this->assertCount(5, $projects); + } + + public function test_workspaces_list() + { + // + } + + public function test_workspaces_show() + { + // + } + + public function test_workspaces_create() + { + // + } + + public function test_workspaces_update() + { + // + } + + public function test_workspaces_remove() + { + // + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index cbeb8d2..0717962 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,17 +2,24 @@ namespace Bitbucket\Tests; +use Bitbucket\Client; +use Bitbucket\HttpClient\Builder; +use Bitbucket\Tests\responses\BaseResponse; +use Http\Mock\Client as MockClient; use PHPUnit\Framework\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { //use CreatesApplication; + /** - * @param $path - * @return string + * @param BaseResponse $response + * @return Client */ - protected function packagePath($path) + protected function getClient(BaseResponse $response) { - return __DIR__.'/../'.$path; + $mock_client = new MockClient($response); + $builder = new Builder($mock_client); + return new Client($builder); } } diff --git a/tests/WorkspacesTest.php b/tests/WorkspacesTest.php index f6790ae..e8cb4c6 100644 --- a/tests/WorkspacesTest.php +++ b/tests/WorkspacesTest.php @@ -2,36 +2,37 @@ namespace Bitbucket\Tests; -use Bitbucket\Api\AbstractApi; -use Bitbucket\Client; -use Bitbucket\HttpClient\Builder; -use GuzzleHttp\Psr7\Response; -use Illuminate\Support\Facades\File; -use Http\Mock\Client as MockClient; -use Psr\Http\Message\ResponseInterface; +use Bitbucket\Tests\responses\WorkspacesListResponse; class WorkspacesTest extends TestCase { - public function test_workspaces_list() + public function test_workspaces_all() { - $path = $this->packagePath('/tests/stubs/workspaces-list-success.json'); - - $mock_client = new MockClient; - - $response = $this->createMock('Bitbucket\Tests\responses\WorkspacesListResponse'); - - $mock_client->setDefaultResponse($response); - - $request = $this->createMock('Psr\Http\Message\RequestInterface'); - - $response = $mock_client->sendRequest($request); + // + } + public function test_workspaces_list() + { + // + } + public function test_workspaces_show() + { + // + } - dd($response->getStatusCode()); + public function test_workspaces_create() + { + // + } - /*$builder = new Builder($mock_client); + public function test_workspaces_update() + { + // + } - $client = new Client($builder);*/ + public function test_workspaces_remove() + { + // } } diff --git a/tests/responses/BaseResponse.php b/tests/responses/BaseResponse.php new file mode 100644 index 0000000..0d9f4a9 --- /dev/null +++ b/tests/responses/BaseResponse.php @@ -0,0 +1,26 @@ +packagePath($path)); + } +} diff --git a/tests/responses/WorkspacesListResponse.php b/tests/responses/WorkspacesListResponse.php index 42ba744..4fb65e0 100644 --- a/tests/responses/WorkspacesListResponse.php +++ b/tests/responses/WorkspacesListResponse.php @@ -1,277 +1,24 @@ getHeaders() as $name => $values) { - * echo $name . ": " . implode(", ", $values); - * } - * - * // Emit headers iteratively: - * foreach ($message->getHeaders() as $name => $values) { - * foreach ($values as $value) { - * header(sprintf('%s: %s', $name, $value), false); - * } - * } - * - * While header names are not case-sensitive, getHeaders() will preserve the - * exact case in which headers were originally specified. - * - * @return string[][] Returns an associative array of the message's headers. Each - * key MUST be a header name, and each value MUST be an array of strings - * for that header. - */ - public function getHeaders() - { - // TODO: Implement getHeaders() method. - } - /** - * Checks if a header exists by the given case-insensitive name. - * - * @param string $name Case-insensitive header field name. - * @return bool Returns true if any header names match the given header - * name using a case-insensitive string comparison. Returns false if - * no matching header name is found in the message. + * @param int $statusCode + * @param null $reasonPhrase + * @param array $headers + * @param null $body + * @param string $protocolVersion + * @return Response|ResponseInterface */ - public function hasHeader($name) - { - // TODO: Implement hasHeader() method. - } - - /** - * Retrieves a message header value by the given case-insensitive name. - * - * This method returns an array of all the header values of the given - * case-insensitive header name. - * - * If the header does not appear in the message, this method MUST return an - * empty array. - * - * @param string $name Case-insensitive header field name. - * @return string[] An array of string values as provided for the given - * header. If the header does not appear in the message, this method MUST - * return an empty array. - */ - public function getHeader($name) - { - // TODO: Implement getHeader() method. - } - - /** - * Retrieves a comma-separated string of the values for a single header. - * - * This method returns all of the header values of the given - * case-insensitive header name as a string concatenated together using - * a comma. - * - * NOTE: Not all header values may be appropriately represented using - * comma concatenation. For such headers, use getHeader() instead - * and supply your own delimiter when concatenating. - * - * If the header does not appear in the message, this method MUST return - * an empty string. - * - * @param string $name Case-insensitive header field name. - * @return string A string of values as provided for the given header - * concatenated together using a comma. If the header does not appear in - * the message, this method MUST return an empty string. - */ - public function getHeaderLine($name) - { - // TODO: Implement getHeaderLine() method. - } - - /** - * Return an instance with the provided value replacing the specified header. - * - * While header names are case-insensitive, the casing of the header will - * be preserved by this function, and returned from getHeaders(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new and/or updated header and value. - * - * @param string $name Case-insensitive header field name. - * @param string|string[] $value Header value(s). - * @return static - * @throws \InvalidArgumentException for invalid header names or values. - */ - public function withHeader($name, $value) - { - // TODO: Implement withHeader() method. - } - - /** - * Return an instance with the specified header appended with the given value. - * - * Existing values for the specified header will be maintained. The new - * value(s) will be appended to the existing list. If the header did not - * exist previously, it will be added. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new header and/or value. - * - * @param string $name Case-insensitive header field name to add. - * @param string|string[] $value Header value(s). - * @return static - * @throws \InvalidArgumentException for invalid header names or values. - */ - public function withAddedHeader($name, $value) - { - // TODO: Implement withAddedHeader() method. - } - - /** - * Return an instance without the specified header. - * - * Header resolution MUST be done without case-sensitivity. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the named header. - * - * @param string $name Case-insensitive header field name to remove. - * @return static - */ - public function withoutHeader($name) - { - // TODO: Implement withoutHeader() method. - } - - /** - * Gets the body of the message. - * - * @return StreamInterface Returns the body as a stream. - */ - public function getBody() - { - // TODO: Implement getBody() method. - } - - /** - * Return an instance with the specified message body. - * - * The body MUST be a StreamInterface object. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return a new instance that has the - * new body stream. - * - * @param StreamInterface $body Body. - * @return static - * @throws \InvalidArgumentException When the body is not valid. - */ - public function withBody(StreamInterface $body) - { - return Stream::factory($this->packagePath('/tests/stubs/workspaces-list-success.json')); - } - - /** - * Gets the response status code. - * - * The status code is a 3-digit integer result code of the server's attempt - * to understand and satisfy the request. - * - * @return int Status code. - */ - public function getStatusCode() - { - return 200; - } - - /** - * Return an instance with the specified status code and, optionally, reason phrase. - * - * If no reason phrase is specified, implementations MAY choose to default - * to the RFC 7231 or IANA recommended reason phrase for the response's - * status code. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated status and reason phrase. - * - * @link http://tools.ietf.org/html/rfc7231#section-6 - * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml - * @param int $code The 3-digit integer result code to set. - * @param string $reasonPhrase The reason phrase to use with the - * provided status code; if none is provided, implementations MAY - * use the defaults as suggested in the HTTP specification. - * @return static - * @throws \InvalidArgumentException For invalid status code arguments. - */ - public function withStatus($code, $reasonPhrase = '') - { - // TODO: Implement withStatus() method. - } - - /** - * Gets the response reason phrase associated with the status code. - * - * Because a reason phrase is not a required element in a response - * status line, the reason phrase value MAY be null. Implementations MAY - * choose to return the default RFC 7231 recommended reason phrase (or those - * listed in the IANA HTTP Status Code Registry) for the response's - * status code. - * - * @link http://tools.ietf.org/html/rfc7231#section-6 - * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml - * @return string Reason phrase; must return an empty string if none present. - */ - public function getReasonPhrase() - { - // TODO: Implement getReasonPhrase() method. - } - - protected function packagePath($path) + public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') { - return __DIR__.'/../'.$path; + $json = $this->getJsonContent('stubs/workspaces-list-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } -} \ No newline at end of file +} diff --git a/tests/stubs/workspaces-list-success.json b/tests/stubs/workspaces-list-success.json index 0098f8f..48c553b 100644 --- a/tests/stubs/workspaces-list-success.json +++ b/tests/stubs/workspaces-list-success.json @@ -5,171 +5,171 @@ "uuid":"{0584df52-5266-40ae-b72e-b72658b09f50}", "links":{ "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92/members?q=permission%3D%22owner%22" + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members?q=permission%3D%22owner%22" }, "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92" + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" }, "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/giacomo92" + "href":"https://api.bitbucket.org/2.0/repositories/john_doe" }, "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/giacomo92" + "href":"https://api.bitbucket.org/2.0/snippets/john_doe" }, "html":{ - "href":"https://bitbucket.org/giacomo92/" + "href":"https://bitbucket.org/john_doe/" }, "avatar":{ - "href":"https://bitbucket.org/workspaces/giacomo92/avatar/?ts=1543645840" + "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1543645840" }, "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92/members" + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members" }, "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/giacomo92/projects" + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects" } }, "created_on":"2018-12-01T06:30:40.906876+00:00", "type":"workspace", - "slug":"giacomo92", + "slug":"john_doe", "is_private":true, - "name":"Giacomo Fabbian" + "name":"John Doe" }, { "uuid":"{36c4305a-34ad-4853-967f-bca30aeeba81}", "links":{ "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/appizza/members?q=permission%3D%22owner%22" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members?q=permission%3D%22owner%22" }, "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/appizza" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1" }, "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/appizza" + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_1" }, "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/appizza" + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_1" }, "html":{ - "href":"https://bitbucket.org/appizza/" + "href":"https://bitbucket.org/atlassian_1/" }, "avatar":{ - "href":"https://bitbucket.org/workspaces/appizza/avatar/?ts=1543645840" + "href":"https://bitbucket.org/workspaces/atlassian_1/avatar/?ts=1543645840" }, "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/appizza/members" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members" }, "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/appizza/projects" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/projects" } }, "created_on":"2018-12-01T06:30:40.921862+00:00", "type":"workspace", - "slug":"appizza", + "slug":"atlassian_1", "is_private":false, - "name":"Appizza" + "name":"atlassian_1" }, { "uuid":"{b5d5d71e-49d3-4917-9390-b88e25ecb2a6}", "links":{ "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo/members?q=permission%3D%22owner%22" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members?q=permission%3D%22owner%22" }, "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian" }, "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/matteogiacomo" + "href":"https://api.bitbucket.org/2.0/repositories/atlassian" }, "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/matteogiacomo" + "href":"https://api.bitbucket.org/2.0/snippets/atlassian" }, "html":{ - "href":"https://bitbucket.org/matteogiacomo/" + "href":"https://bitbucket.org/atlassian/" }, "avatar":{ - "href":"https://bitbucket.org/workspaces/matteogiacomo/avatar/?ts=1543668122" + "href":"https://bitbucket.org/workspaces/atlassian/avatar/?ts=1543668122" }, "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo/members" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members" }, "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/matteogiacomo/projects" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/projects" } }, "created_on":"2018-12-01T12:42:02.071886+00:00", "type":"workspace", - "slug":"matteogiacomo", + "slug":"atlassian", "is_private":false, - "name":"matteogiacomo" + "name":"Atlassian" }, { "uuid":"{5b98396b-d55e-44ae-8559-46b55559ebe2}", "links":{ "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/jack_0/members?q=permission%3D%22owner%22" + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members?q=permission%3D%22owner%22" }, "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/jack_0" + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe" }, "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/jack_0" + "href":"https://api.bitbucket.org/2.0/repositories/bill_doe" }, "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/jack_0" + "href":"https://api.bitbucket.org/2.0/snippets/bill_doe" }, "html":{ - "href":"https://bitbucket.org/jack_0/" + "href":"https://bitbucket.org/bill_doe/" }, "avatar":{ - "href":"https://bitbucket.org/workspaces/jack_0/avatar/?ts=1543675270" + "href":"https://bitbucket.org/workspaces/bill_doe/avatar/?ts=1543675270" }, "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/jack_0/members" + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members" }, "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/jack_0/projects" + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/projects" } }, "created_on":"2018-12-01T14:41:10.784154+00:00", "type":"workspace", - "slug":"jack_0", + "slug":"bill_doe", "is_private":false, - "name":"jack_0" + "name":"Bill Doe" }, { "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", "links":{ "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency/members?q=permission%3D%22owner%22" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/members?q=permission%3D%22owner%22" }, "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2" }, "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/offlineagency" + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_2" }, "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/offlineagency" + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_2" }, "html":{ - "href":"https://bitbucket.org/offlineagency/" + "href":"https://bitbucket.org/atlassian_2/" }, "avatar":{ - "href":"https://bitbucket.org/workspaces/offlineagency/avatar/?ts=1571998380" + "href":"https://bitbucket.org/workspaces/atlassian_2/avatar/?ts=1571998380" }, "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency/members" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/members" }, "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/offlineagency/projects" + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/projects" } }, "created_on":"2019-10-25T10:13:00.687887+00:00", "type":"workspace", - "slug":"offlineagency", + "slug":"atlassian_2", "is_private":false, - "name":"offline-agency" + "name":"Atlassian 2" } ], "page":1, From 94e6840599382c5e138cb14e51294878c22c9639 Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 12:56:37 +0200 Subject: [PATCH 03/21] [NS] update tests --- src/Api/Teams/Projects.php | 20 +- src/Api/Workspaces.php | 29 + tests/ProjectsTest.php | 71 ++- tests/WorkspacesTest.php | 33 +- tests/responses/ProjectCreateResponse.php | 25 + tests/responses/ProjectRemoveResponse.php | 25 + tests/responses/ProjectUpdateResponse.php | 25 + tests/responses/ProjectsAllResponse.php | 25 + tests/responses/ProjectsListResponse.php | 24 + tests/responses/ProjectsShowResponse.php | 24 + tests/responses/WorkspacesAllResponse.php | 24 + tests/responses/WorkspacesShowResponse.php | 24 + tests/stubs/project-create-success.json | 58 ++ tests/stubs/project-remove-success.json | 3 + tests/stubs/project-update-success.json | 58 ++ tests/stubs/projects-all-success.json | 645 +++++++++++++++++++++ tests/stubs/projects-list-success.json | 529 +++++++++++++++++ tests/stubs/projects-show-success.json | 58 ++ tests/stubs/workspaces-all-success.json | 381 ++++++++++++ tests/stubs/workspaces-list-success.json | 316 +++++----- tests/stubs/workspaces-show-success.json | 34 ++ 21 files changed, 2222 insertions(+), 209 deletions(-) create mode 100644 tests/responses/ProjectCreateResponse.php create mode 100644 tests/responses/ProjectRemoveResponse.php create mode 100644 tests/responses/ProjectUpdateResponse.php create mode 100644 tests/responses/ProjectsAllResponse.php create mode 100644 tests/responses/ProjectsListResponse.php create mode 100644 tests/responses/ProjectsShowResponse.php create mode 100644 tests/responses/WorkspacesAllResponse.php create mode 100644 tests/responses/WorkspacesShowResponse.php create mode 100644 tests/stubs/project-create-success.json create mode 100644 tests/stubs/project-remove-success.json create mode 100644 tests/stubs/project-update-success.json create mode 100644 tests/stubs/projects-all-success.json create mode 100644 tests/stubs/projects-list-success.json create mode 100644 tests/stubs/projects-show-success.json create mode 100644 tests/stubs/workspaces-all-success.json create mode 100644 tests/stubs/workspaces-show-success.json diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index 64e2375..99842ee 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -102,14 +102,30 @@ public function show(string $project, array $params = []) /** * @param string $project - * @param array $params + * @param string $name + * @param string $key + * @param string $description + * @param string $links + * @param bool $is_private * * @throws Exception * * @return array */ - public function update(string $project, array $params = []) + public function update(string $project, string $name, string $key, string $description, string $links, bool $is_private) { + $params = [ + 'name' => $name, + 'key' => $key, + 'description' => $description, + 'links' => (object)[ + 'avatar' => (object)[ + 'href' => $links + ] + ], + 'is_private' => $is_private + ]; + $path = $this->buildProjectsPath($project); return $this->put($path, $params); diff --git a/src/Api/Workspaces.php b/src/Api/Workspaces.php index 5bfc989..cc579b6 100644 --- a/src/Api/Workspaces.php +++ b/src/Api/Workspaces.php @@ -29,6 +29,35 @@ public function list(array $params = []) return $this->get($path, $params); } + public function all() + { + $workspaces = []; + $page = 1; + + do { + $workspace = $this->list(['page' => $page]); + $workspaces = array_merge($workspaces, $workspace['values']); + $page++; + } while (isset($workspace['next'])); + + return $workspaces; + } + + /** + * @param string $workspace + * @param array $params + * + * @return array + * + * @throws \Http\Client\Exception + */ + public function show(string $workspace, array $params = []) + { + $path = $this->buildWorkspacePath($workspace); + + return $this->get($path, $params); + } + /** * Build the workspaces path from the given parts. * diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index 1f06cb9..f54fb35 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -2,41 +2,82 @@ namespace Bitbucket\Tests; -use Bitbucket\Tests\responses\WorkspacesListResponse; +use Bitbucket\Tests\responses\ProjectCreateResponse; +use Bitbucket\Tests\responses\ProjectsAllResponse; +use Bitbucket\Tests\responses\ProjectsListResponse; +use Bitbucket\Tests\responses\ProjectsShowResponse; +use Bitbucket\Tests\responses\ProjectUpdateResponse; class ProjectsTest extends TestCase { - public function test_workspaces_all() + public function test_projects_all() { - $response = new WorkspacesListResponse(); + $response = new ProjectsAllResponse(); $client = $this->getClient($response); - $projects = $client->teams('test')->projects()->all(); + $projects = $client->teams('john_doe')->projects()->all(); - $this->assertCount(5, $projects); + $this->assertCount(11, $projects); } - public function test_workspaces_list() + public function test_projects_list() //TODO sistemare { - // + $response = new ProjectsListResponse(); + $client = $this->getClient($response); + $projects = $client->teams('john_doe')->projects()->list(); + + $this->assertCount(9, $projects); } - public function test_workspaces_show() + public function test_project_show() { - // + $response = new ProjectsShowResponse(); + $client = $this->getClient($response); + $project = $client->teams('john_doe')->projects()->show('Atlassian1'); + + $this->assertCount(11, $project); //TODO aggiungere check } - public function test_workspaces_create() + public function test_project_create() { - // + $response = new ProjectCreateResponse(); + $client = $this->getClient($response); + $project = $client->teams('john_doe')->projects()->create( + 'name', + 'key', + 'description', + 'links', + true + ); + + $this->assertCount(11, $project); //TODO aggiungere check } - public function test_workspaces_update() + public function test_project_update() { - // + $response = new ProjectUpdateResponse(); + $client = $this->getClient($response); + + $project = $client->teams('john_doe')->projects()->update( + 'Atlassian1', + 'name-updated', + 'Atlassian1', + 'description-updated', + '', + true + ); + + $this->assertCount(11, $project); //TODO aggiungere check e response } - public function test_workspaces_remove() + public function test_project_remove() { - // + $response = new ProjectUpdateResponse(); + $client = $this->getClient($response); + + $project = $client->teams('john_doe')->projects()->remove( + 'Atlassian1' + ); + + $this->assertCount(11, $project); //TODO aggiungere check e response } } diff --git a/tests/WorkspacesTest.php b/tests/WorkspacesTest.php index e8cb4c6..01e3144 100644 --- a/tests/WorkspacesTest.php +++ b/tests/WorkspacesTest.php @@ -2,37 +2,36 @@ namespace Bitbucket\Tests; +use Bitbucket\Tests\responses\WorkspacesAllResponse; use Bitbucket\Tests\responses\WorkspacesListResponse; +use Bitbucket\Tests\responses\WorkspacesShowResponse; class WorkspacesTest extends TestCase { public function test_workspaces_all() { - // - } + $response = new WorkspacesAllResponse(); + $client = $this->getClient($response); + $workspaces = $client->workspaces()->all(); - public function test_workspaces_list() - { - // + $this->assertCount(11, $workspaces); } - public function test_workspaces_show() + public function test_workspaces_list() { - // - } + $response = new WorkspacesListResponse(); + $client = $this->getClient($response); + $workspaces = $client->workspaces()->list(); - public function test_workspaces_create() - { - // + $this->assertCount(4, $workspaces); } - public function test_workspaces_update() + public function test_workspace_show() { - // - } + $response = new WorkspacesShowResponse(); + $client = $this->getClient($response); + $workspace = $client->workspaces()->show('john_doe'); - public function test_workspaces_remove() - { - // + $this->assertCount(7, $workspace); //TODO fare ulteriori check } } diff --git a/tests/responses/ProjectCreateResponse.php b/tests/responses/ProjectCreateResponse.php new file mode 100644 index 0000000..f9c96d5 --- /dev/null +++ b/tests/responses/ProjectCreateResponse.php @@ -0,0 +1,25 @@ +getJsonContent('stubs/project-create-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); + } +} \ No newline at end of file diff --git a/tests/responses/ProjectRemoveResponse.php b/tests/responses/ProjectRemoveResponse.php new file mode 100644 index 0000000..876feb0 --- /dev/null +++ b/tests/responses/ProjectRemoveResponse.php @@ -0,0 +1,25 @@ +getJsonContent('stubs/project-remove-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); + } +} \ No newline at end of file diff --git a/tests/responses/ProjectUpdateResponse.php b/tests/responses/ProjectUpdateResponse.php new file mode 100644 index 0000000..fee9017 --- /dev/null +++ b/tests/responses/ProjectUpdateResponse.php @@ -0,0 +1,25 @@ +getJsonContent('stubs/project-update-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); + } +} \ No newline at end of file diff --git a/tests/responses/ProjectsAllResponse.php b/tests/responses/ProjectsAllResponse.php new file mode 100644 index 0000000..5d80aec --- /dev/null +++ b/tests/responses/ProjectsAllResponse.php @@ -0,0 +1,25 @@ +getJsonContent('stubs/projects-all-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); + } +} \ No newline at end of file diff --git a/tests/responses/ProjectsListResponse.php b/tests/responses/ProjectsListResponse.php new file mode 100644 index 0000000..011b9db --- /dev/null +++ b/tests/responses/ProjectsListResponse.php @@ -0,0 +1,24 @@ +getJsonContent('stubs/projects-list-success.json'); + return new Response($statusCode, ['Content-Type' => 'application/json'], $json); + } +} diff --git a/tests/responses/ProjectsShowResponse.php b/tests/responses/ProjectsShowResponse.php new file mode 100644 index 0000000..dfb468f --- /dev/null +++ b/tests/responses/ProjectsShowResponse.php @@ -0,0 +1,24 @@ +getJsonContent('stubs/projects-show-success.json'); + return new Response($statusCode, ['Content-Type' => 'application/json'], $json); + } +} diff --git a/tests/responses/WorkspacesAllResponse.php b/tests/responses/WorkspacesAllResponse.php new file mode 100644 index 0000000..77ce44a --- /dev/null +++ b/tests/responses/WorkspacesAllResponse.php @@ -0,0 +1,24 @@ +getJsonContent('stubs/workspaces-all-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); + } +} diff --git a/tests/responses/WorkspacesShowResponse.php b/tests/responses/WorkspacesShowResponse.php new file mode 100644 index 0000000..b9ed15c --- /dev/null +++ b/tests/responses/WorkspacesShowResponse.php @@ -0,0 +1,24 @@ +getJsonContent('stubs/workspaces-show-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); + } +} diff --git a/tests/stubs/project-create-success.json b/tests/stubs/project-create-success.json new file mode 100644 index 0000000..7214a39 --- /dev/null +++ b/tests/stubs/project-create-success.json @@ -0,0 +1,58 @@ +{ + "description":"description", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects/TEST" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/workspace/projects/TEST" + }, + "repositories":[ + + ], + "avatar":{ + "href":"" + } + }, + "uuid":"{4762738f-3caa-44f7-8dd2-bd25237f7ade}", + "created_on":"2020-06-29T10:24:26.594408+00:00", + "workspace":{ + "slug":"john_doe", + "type":"workspace", + "name":"john-doe", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"key", + "owner":{ + "username":"john_doe", + "display_name":"john-doe", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar":{ + "href":"https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on":"2020-06-29T10:24:26.594431+00:00", + "type":"project", + "is_private":true, + "name":"name" +} \ No newline at end of file diff --git a/tests/stubs/project-remove-success.json b/tests/stubs/project-remove-success.json new file mode 100644 index 0000000..0e0dcd2 --- /dev/null +++ b/tests/stubs/project-remove-success.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/tests/stubs/project-update-success.json b/tests/stubs/project-update-success.json new file mode 100644 index 0000000..e9241e0 --- /dev/null +++ b/tests/stubs/project-update-success.json @@ -0,0 +1,58 @@ +{ + "description":"description-updated", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian1" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/workspace/projects/Atlassian1" + }, + "repositories":[ + + ], + "avatar":{ + "href":"" + } + }, + "uuid":"{4762738f-3caa-44f7-8dd2-bd25237f7ade}", + "created_on":"2020-06-29T10:24:26.594408+00:00", + "workspace":{ + "slug":"john_doe", + "type":"workspace", + "name":"john-doe", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"Atlassian1", + "owner":{ + "username":"john_doe", + "display_name":"john-doe", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar":{ + "href":"https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on":"2020-06-29T10:35:50.718200+00:00", + "type":"project", + "is_private":true, + "name":"name-updated" +} \ No newline at end of file diff --git a/tests/stubs/projects-all-success.json b/tests/stubs/projects-all-success.json new file mode 100644 index 0000000..6e4ae62 --- /dev/null +++ b/tests/stubs/projects-all-success.json @@ -0,0 +1,645 @@ +{ + "pagelen": 100, + "values": [ + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian1" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian1" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian1\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian1/avatar/32?ts=1592993838" + } + }, + "uuid": "{f38daeea-d64f-44f7-afc8-f972d09b1d08}", + "created_on": "2020-06-24T10:17:18.875720+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian1", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2020-06-24T10:17:18.875739+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian1" + }, + { + "description": null, + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian2" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian2" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian2\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian2/avatar/32?ts=1589292488" + } + }, + "uuid": "{320ae6b5-04a2-495e-8ef2-642cd50817ba}", + "created_on": "2020-05-12T14:08:08.062102+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian2", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2020-05-12T14:08:08.062141+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian2" + }, + { + "description": null, + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian3" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian3" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian3\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian3/avatar/32?ts=1588922476" + } + }, + "uuid": "{fa26f90b-26bb-4ce5-9253-1ba44c5307df}", + "created_on": "2020-05-08T07:21:16.638095+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian3", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2020-05-08T07:21:16.638109+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian3" + }, + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian4" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian4" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian4\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian4/avatar/32?ts=1582298430" + } + }, + "uuid": "{6a489fd0-08a4-4915-9e64-4add52c0b1e6}", + "created_on": "2020-02-21T15:19:50.594200+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian4", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2020-02-21T15:20:30.301162+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian4" + }, + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian5" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian5" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian5\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian5/avatar/32?ts=1580310154" + } + }, + "uuid": "{a04d2b8e-04b5-4dbb-abad-a10517d9f418}", + "created_on": "2020-01-29T15:02:34.818938+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian5", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2020-01-29T15:02:34.818955+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian5" + }, + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian6" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian6" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian6\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian6/avatar/32?ts=1574078583" + } + }, + "uuid": "{81f98281-973f-4cf2-a6a9-8a31e3872211}", + "created_on": "2019-11-18T11:59:29.084414+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian6", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2019-11-18T12:03:03.696455+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian6" + }, + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian7" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian7" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian7\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian7/avatar/32?ts=1593011466" + } + }, + "uuid": "{95d40011-a2ef-4e27-ba05-899e0fa9b3bd}", + "created_on": "2019-11-06T14:25:50.773844+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian7", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2020-06-24T15:11:06.066911+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian7" + }, + { + "description": null, + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian8" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian8" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian8\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian8/avatar/32?ts=1572018611" + } + }, + "uuid": "{07be1185-daff-4879-b75e-9f9d1a10fcb1}", + "created_on": "2019-10-25T15:50:11.938768+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian8", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2019-10-25T15:50:11.938787+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian8" + }, + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian9" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian9" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian9\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian9/avatar/32?ts=1571998444" + } + }, + "uuid": "{9b15c9a7-6d6f-4639-ae23-c86307e19a89}", + "created_on": "2019-10-25T10:14:04.450212+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian9", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2019-10-25T10:14:04.450232+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian9" + }, + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian10" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian10" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian10\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian10/avatar/32?ts=1571998444" + } + }, + "uuid": "{9b15c9a7-6d6f-4639-ae23-c86307e19a89}", + "created_on": "2019-10-25T10:14:04.450212+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian10", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2019-10-25T10:14:04.450232+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian10" + }, + { + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian11" + }, + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian11" + }, + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian11\"" + }, + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian11/avatar/32?ts=1571998444" + } + }, + "uuid": "{9b15c9a7-6d6f-4639-ae23-c86307e19a89}", + "created_on": "2019-10-25T10:14:04.450212+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key": "Atlassian11", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on": "2019-10-25T10:14:04.450232+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian11" + } + ], + "page": 1, + "size": 11 +} \ No newline at end of file diff --git a/tests/stubs/projects-list-success.json b/tests/stubs/projects-list-success.json new file mode 100644 index 0000000..5db6534 --- /dev/null +++ b/tests/stubs/projects-list-success.json @@ -0,0 +1,529 @@ +{ + "pagelen":50, + "values":[ + { + "description":"", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/APPIZZA" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/APPIZZA" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"APPIZZA\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/APPIZZA\/avatar\/32?ts=1592993838" + } + }, + "uuid":"{f38daeea-d64f-44f7-afc8-f972d09b1d08}", + "created_on":"2020-06-24T10:17:18.875720+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"APPIZZA", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2020-06-24T10:17:18.875739+00:00", + "type":"project", + "is_private":true, + "name":"Appizzachepizza" + }, + { + "description":null, + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/NEIG" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/NEIG" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"NEIG\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/NEIG\/avatar\/32?ts=1589292488" + } + }, + "uuid":"{320ae6b5-04a2-495e-8ef2-642cd50817ba}", + "created_on":"2020-05-12T14:08:08.062102+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"NEIG", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2020-05-12T14:08:08.062141+00:00", + "type":"project", + "is_private":false, + "name":"neighborhood" + }, + { + "description":null, + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/UN" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/UN" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"UN\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/UN\/avatar\/32?ts=1588922476" + } + }, + "uuid":"{fa26f90b-26bb-4ce5-9253-1ba44c5307df}", + "created_on":"2020-05-08T07:21:16.638095+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"UN", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2020-05-08T07:21:16.638109+00:00", + "type":"project", + "is_private":false, + "name":"uncode" + }, + { + "description":"", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/SPEAK" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/SPEAK" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"SPEAK\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/SPEAK\/avatar\/32?ts=1582298430" + } + }, + "uuid":"{6a489fd0-08a4-4915-9e64-4add52c0b1e6}", + "created_on":"2020-02-21T15:19:50.594200+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"SPEAK", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2020-02-21T15:20:30.301162+00:00", + "type":"project", + "is_private":false, + "name":"speak-out" + }, + { + "description":"", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/ATS" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/ATS" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"ATS\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/ATS\/avatar\/32?ts=1580310154" + } + }, + "uuid":"{a04d2b8e-04b5-4dbb-abad-a10517d9f418}", + "created_on":"2020-01-29T15:02:34.818938+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"ATS", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2020-01-29T15:02:34.818955+00:00", + "type":"project", + "is_private":true, + "name":"ATS" + }, + { + "description":"", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/PENTA" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/PENTA" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"PENTA\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/PENTA\/avatar\/32?ts=1574078583" + } + }, + "uuid":"{81f98281-973f-4cf2-a6a9-8a31e3872211}", + "created_on":"2019-11-18T11:59:29.084414+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"PENTA", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2019-11-18T12:03:03.696455+00:00", + "type":"project", + "is_private":true, + "name":"Pentaidinnovation" + }, + { + "description":"", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/ESTE" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/ESTE" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"ESTE\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/ESTE\/avatar\/32?ts=1593011466" + } + }, + "uuid":"{95d40011-a2ef-4e27-ba05-899e0fa9b3bd}", + "created_on":"2019-11-06T14:25:50.773844+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"ESTE", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2020-06-24T15:11:06.066911+00:00", + "type":"project", + "is_private":false, + "name":"Estensione" + }, + { + "description":null, + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/OA" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/OA" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"OA\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/OA\/avatar\/32?ts=1572018611" + } + }, + "uuid":"{07be1185-daff-4879-b75e-9f9d1a10fcb1}", + "created_on":"2019-10-25T15:50:11.938768+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"OA", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2019-10-25T15:50:11.938787+00:00", + "type":"project", + "is_private":false, + "name":"Offline Agency" + }, + { + "description":"", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/MC" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/MC" + }, + "repositories":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"MC\"" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/MC\/avatar\/32?ts=1571998444" + } + }, + "uuid":"{9b15c9a7-6d6f-4639-ae23-c86307e19a89}", + "created_on":"2019-10-25T10:14:04.450212+00:00", + "workspace":{ + "slug":"offlineagency", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/offlineagency\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"MC", + "owner":{ + "username":"offlineagency", + "display_name":"offline-agency", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" + }, + "avatar":{ + "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + } + } + }, + "updated_on":"2019-10-25T10:14:04.450232+00:00", + "type":"project", + "is_private":true, + "name":"Mariangela Caforio" + } + ], + "page":1, + "size":9 +} \ No newline at end of file diff --git a/tests/stubs/projects-show-success.json b/tests/stubs/projects-show-success.json new file mode 100644 index 0000000..a8a1342 --- /dev/null +++ b/tests/stubs/projects-show-success.json @@ -0,0 +1,58 @@ +{ + "description":"", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian1" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/workspace/projects/Atlassian1" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian1\"" + }, + "avatar":{ + "href":"https://bitbucket.org/account/user/john_doe/projects/Atlassian1/avatar/32?ts=1571998444" + } + }, + "uuid":"{9b15c9a7-6d6f-4639-ae23-c86307e19a89}", + "created_on":"2019-10-25T10:14:04.450212+00:00", + "workspace":{ + "slug":"john_doe", + "type":"workspace", + "name":"offline-agency", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + } + }, + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + }, + "key":"Atlassian1", + "owner":{ + "username":"john_doe", + "display_name":"john-doe", + "type":"team", + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "self":{ + "href":"https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html":{ + "href":"https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar":{ + "href":"https://bitbucket.org/account/john_doe/avatar/" + } + } + }, + "updated_on":"2019-10-25T10:14:04.450232+00:00", + "type":"project", + "is_private":true, + "name":"Atlassian1" +} \ No newline at end of file diff --git a/tests/stubs/workspaces-all-success.json b/tests/stubs/workspaces-all-success.json new file mode 100644 index 0000000..094dd77 --- /dev/null +++ b/tests/stubs/workspaces-all-success.json @@ -0,0 +1,381 @@ +{ + "pagelen":50, + "values":[ + { + "uuid":"{0584df52-5266-40ae-b72e-b72658b09f50}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/john_doe" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/john_doe" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1543645840" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects" + } + }, + "created_on":"2018-12-01T06:30:40.906876+00:00", + "type":"workspace", + "slug":"john_doe", + "is_private":true, + "name":"John Doe" + }, + { + "uuid":"{36c4305a-34ad-4853-967f-bca30aeeba81}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_1" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_1" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_1/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_1/avatar/?ts=1543645840" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/projects" + } + }, + "created_on":"2018-12-01T06:30:40.921862+00:00", + "type":"workspace", + "slug":"atlassian_1", + "is_private":false, + "name":"atlassian_1" + }, + { + "uuid":"{b5d5d71e-49d3-4917-9390-b88e25ecb2a6}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian" + }, + "html":{ + "href":"https://bitbucket.org/atlassian/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian/avatar/?ts=1543668122" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/projects" + } + }, + "created_on":"2018-12-01T12:42:02.071886+00:00", + "type":"workspace", + "slug":"atlassian", + "is_private":false, + "name":"Atlassian" + }, + { + "uuid":"{5b98396b-d55e-44ae-8559-46b55559ebe2}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/bill_doe" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/bill_doe" + }, + "html":{ + "href":"https://bitbucket.org/bill_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/bill_doe/avatar/?ts=1543675270" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/projects" + } + }, + "created_on":"2018-12-01T14:41:10.784154+00:00", + "type":"workspace", + "slug":"bill_doe", + "is_private":false, + "name":"Bill Doe" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_2" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_2" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_2/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_2/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"atlassian_2", + "is_private":false, + "name":"Atlassian 2" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_3/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_3" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_3" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_3" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_3/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_3/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_3/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_3/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"atlassian_3", + "is_private":false, + "name":"Atlassian 3" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_4/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_4" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_4" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_4" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_4/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_4/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_4/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_4/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"atlassian_4", + "is_private":false, + "name":"Atlassian 4" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_5/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_5" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_5" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_5" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_5/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_5/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_5/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_5/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"atlassian_5", + "is_private":false, + "name":"Atlassian 5" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_6/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_6" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_6" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_6" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_6/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_6/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_6/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_6/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"atlassian_6", + "is_private":false, + "name":"Atlassian 6" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_7/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_7" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_7" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_7" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_7/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_7/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_7/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_7/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"atlassian_7", + "is_private":false, + "name":"Atlassian 7" + }, + { + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_8/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_8" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_8" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_8" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_8/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_8/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_8/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_8/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"atlassian_8", + "is_private":false, + "name":"Atlassian 8" + } + ], + "page":1, + "size":11 +} diff --git a/tests/stubs/workspaces-list-success.json b/tests/stubs/workspaces-list-success.json index 48c553b..f12274d 100644 --- a/tests/stubs/workspaces-list-success.json +++ b/tests/stubs/workspaces-list-success.json @@ -1,177 +1,143 @@ { - "pagelen":10, - "values":[ - { - "uuid":"{0584df52-5266-40ae-b72e-b72658b09f50}", - "links":{ - "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members?q=permission%3D%22owner%22" - }, - "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" - }, - "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/john_doe" - }, - "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/john_doe" - }, - "html":{ - "href":"https://bitbucket.org/john_doe/" - }, - "avatar":{ - "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1543645840" - }, - "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members" - }, - "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects" - } - }, - "created_on":"2018-12-01T06:30:40.906876+00:00", - "type":"workspace", - "slug":"john_doe", - "is_private":true, - "name":"John Doe" - }, - { - "uuid":"{36c4305a-34ad-4853-967f-bca30aeeba81}", - "links":{ - "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members?q=permission%3D%22owner%22" - }, - "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1" - }, - "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/atlassian_1" - }, - "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/atlassian_1" - }, - "html":{ - "href":"https://bitbucket.org/atlassian_1/" - }, - "avatar":{ - "href":"https://bitbucket.org/workspaces/atlassian_1/avatar/?ts=1543645840" - }, - "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members" - }, - "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/projects" - } - }, - "created_on":"2018-12-01T06:30:40.921862+00:00", - "type":"workspace", - "slug":"atlassian_1", - "is_private":false, - "name":"atlassian_1" - }, - { - "uuid":"{b5d5d71e-49d3-4917-9390-b88e25ecb2a6}", - "links":{ - "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members?q=permission%3D%22owner%22" - }, - "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian" - }, - "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/atlassian" - }, - "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/atlassian" - }, - "html":{ - "href":"https://bitbucket.org/atlassian/" - }, - "avatar":{ - "href":"https://bitbucket.org/workspaces/atlassian/avatar/?ts=1543668122" - }, - "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members" - }, - "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/projects" - } - }, - "created_on":"2018-12-01T12:42:02.071886+00:00", - "type":"workspace", - "slug":"atlassian", - "is_private":false, - "name":"Atlassian" - }, - { - "uuid":"{5b98396b-d55e-44ae-8559-46b55559ebe2}", - "links":{ - "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members?q=permission%3D%22owner%22" - }, - "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe" - }, - "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/bill_doe" - }, - "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/bill_doe" - }, - "html":{ - "href":"https://bitbucket.org/bill_doe/" - }, - "avatar":{ - "href":"https://bitbucket.org/workspaces/bill_doe/avatar/?ts=1543675270" - }, - "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members" - }, - "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/projects" - } - }, - "created_on":"2018-12-01T14:41:10.784154+00:00", - "type":"workspace", - "slug":"bill_doe", - "is_private":false, - "name":"Bill Doe" - }, - { - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "owners":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/members?q=permission%3D%22owner%22" - }, - "self":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2" - }, - "repositories":{ - "href":"https://api.bitbucket.org/2.0/repositories/atlassian_2" - }, - "snippets":{ - "href":"https://api.bitbucket.org/2.0/snippets/atlassian_2" - }, - "html":{ - "href":"https://bitbucket.org/atlassian_2/" - }, - "avatar":{ - "href":"https://bitbucket.org/workspaces/atlassian_2/avatar/?ts=1571998380" - }, - "members":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/members" - }, - "projects":{ - "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_2/projects" - } - }, - "created_on":"2019-10-25T10:13:00.687887+00:00", - "type":"workspace", - "slug":"atlassian_2", - "is_private":false, - "name":"Atlassian 2" + "pagelen":10, + "values":[ + { + "uuid":"{0584df52-5266-40ae-b72e-b72658b09f50}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/john_doe" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/john_doe" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1543645840" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects" + } + }, + "created_on":"2018-12-01T06:30:40.906876+00:00", + "type":"workspace", + "slug":"john_doe", + "is_private":true, + "name":"John Doe" + }, + { + "uuid":"{36c4305a-34ad-4853-967f-bca30aeeba81}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian_1" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian_1" + }, + "html":{ + "href":"https://bitbucket.org/atlassian_1/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian_1/avatar/?ts=1543645840" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian_1/projects" + } + }, + "created_on":"2018-12-01T06:30:40.921862+00:00", + "type":"workspace", + "slug":"atlassian_1", + "is_private":false, + "name":"atlassian_1" + }, + { + "uuid":"{b5d5d71e-49d3-4917-9390-b88e25ecb2a6}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/atlassian" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/atlassian" + }, + "html":{ + "href":"https://bitbucket.org/atlassian/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/atlassian/avatar/?ts=1543668122" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/atlassian/projects" + } + }, + "created_on":"2018-12-01T12:42:02.071886+00:00", + "type":"workspace", + "slug":"atlassian", + "is_private":false, + "name":"atlassian" + }, + { + "uuid":"{5b98396b-d55e-44ae-8559-46b55559ebe2}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/bill_doe" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/bill_doe" + }, + "html":{ + "href":"https://bitbucket.org/bill_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/bill_doe/avatar/?ts=1543675270" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/bill_doe/projects" } - ], - "page":1, - "size":5 -} + }, + "created_on":"2018-12-01T14:41:10.784154+00:00", + "type":"workspace", + "slug":"bill_doe", + "is_private":false, + "name":"bill_doe" + } + ], + "page":1, + "size":4 +} \ No newline at end of file diff --git a/tests/stubs/workspaces-show-success.json b/tests/stubs/workspaces-show-success.json new file mode 100644 index 0000000..3723d19 --- /dev/null +++ b/tests/stubs/workspaces-show-success.json @@ -0,0 +1,34 @@ +{ + "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links":{ + "owners":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members?q=permission%3D%22owner%22" + }, + "self":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "repositories":{ + "href":"https://api.bitbucket.org/2.0/repositories/john_doe" + }, + "snippets":{ + "href":"https://api.bitbucket.org/2.0/snippets/john_doe" + }, + "html":{ + "href":"https://bitbucket.org/john_doe/" + }, + "avatar":{ + "href":"https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" + }, + "members":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/members" + }, + "projects":{ + "href":"https://api.bitbucket.org/2.0/workspaces/john_doe/projects" + } + }, + "created_on":"2019-10-25T10:13:00.687887+00:00", + "type":"workspace", + "slug":"john_doe", + "is_private":false, + "name":"John Doe" +} \ No newline at end of file From 7d0694068d544ceed069158c006a20d9b7f2cfb2 Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 15:01:10 +0200 Subject: [PATCH 04/21] [GF] Removed unused dependency + add test script for composer --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f596546..68e9c65 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,6 @@ "php-http/cache-plugin": "^1.6", "php-http/client-implementation": "^1.0", "php-http/client-common": "^1.9|^2.0", - "illuminate/support": "^5.8|^6.0", "php-http/multipart-stream-builder": "^1.0", "php-http/mock-client": "^1.3" }, @@ -38,6 +37,9 @@ "Bitbucket\\Tests\\": "tests/" } }, + "scripts": { + "test": "vendor/bin/phpunit" + }, "config": { "preferred-install": "dist" }, From be8ce6ba306df4f707f2e588b1286a29af892c1f Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 15:03:59 +0200 Subject: [PATCH 05/21] [GF] Fix ci --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 68e9c65..b83ad4b 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "graham-campbell/analyzer": "^2.4", "orchestra/testbench": "^3.1|^4.0", "php-http/guzzle6-adapter": "^1.1|^2.0", - "phpunit/phpunit": "^9.2" + "phpunit/phpunit": "^7.5|^8.5|^9.0" }, "autoload": { "psr-4": { From fc710b293037fe592f172780ffdf9868165cf9d4 Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 15:19:21 +0200 Subject: [PATCH 06/21] [GF] Removed unused dependencies --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index b83ad4b..b7bf0d7 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ }, "require-dev": { "graham-campbell/analyzer": "^2.4", - "orchestra/testbench": "^3.1|^4.0", "php-http/guzzle6-adapter": "^1.1|^2.0", "phpunit/phpunit": "^7.5|^8.5|^9.0" }, From 938480b1462fbfda4296473072c86ca8eacd3bb5 Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 15:20:19 +0200 Subject: [PATCH 07/21] [NS] fix tests --- tests/ProjectsTest.php | 13 +++++++------ tests/stubs/project-remove-success.json | 4 +--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index f54fb35..2d6be69 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -3,6 +3,7 @@ namespace Bitbucket\Tests; use Bitbucket\Tests\responses\ProjectCreateResponse; +use Bitbucket\Tests\responses\ProjectRemoveResponse; use Bitbucket\Tests\responses\ProjectsAllResponse; use Bitbucket\Tests\responses\ProjectsListResponse; use Bitbucket\Tests\responses\ProjectsShowResponse; @@ -19,7 +20,7 @@ public function test_projects_all() $this->assertCount(11, $projects); } - public function test_projects_list() //TODO sistemare + public function test_projects_list() { $response = new ProjectsListResponse(); $client = $this->getClient($response); @@ -34,7 +35,7 @@ public function test_project_show() $client = $this->getClient($response); $project = $client->teams('john_doe')->projects()->show('Atlassian1'); - $this->assertCount(11, $project); //TODO aggiungere check + $this->assertCount(11, $project); } public function test_project_create() @@ -49,7 +50,7 @@ public function test_project_create() true ); - $this->assertCount(11, $project); //TODO aggiungere check + $this->assertCount(11, $project); } public function test_project_update() @@ -66,18 +67,18 @@ public function test_project_update() true ); - $this->assertCount(11, $project); //TODO aggiungere check e response + $this->assertCount(11, $project); } public function test_project_remove() { - $response = new ProjectUpdateResponse(); + $response = new ProjectRemoveResponse(); $client = $this->getClient($response); $project = $client->teams('john_doe')->projects()->remove( 'Atlassian1' ); - $this->assertCount(11, $project); //TODO aggiungere check e response + $this->assertCount(0, $project); } } diff --git a/tests/stubs/project-remove-success.json b/tests/stubs/project-remove-success.json index 0e0dcd2..9e26dfe 100644 --- a/tests/stubs/project-remove-success.json +++ b/tests/stubs/project-remove-success.json @@ -1,3 +1 @@ -{ - -} \ No newline at end of file +{} \ No newline at end of file From 685fec894b47e265278041c30d34ec5dff4584eb Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 15:24:40 +0200 Subject: [PATCH 08/21] [GF] Fix test and removed composer script --- composer.json | 3 --- tests/CreatesApplication.php | 18 ------------------ tests/TestCase.php | 2 -- 3 files changed, 23 deletions(-) delete mode 100644 tests/CreatesApplication.php diff --git a/composer.json b/composer.json index b7bf0d7..dea0419 100644 --- a/composer.json +++ b/composer.json @@ -36,9 +36,6 @@ "Bitbucket\\Tests\\": "tests/" } }, - "scripts": { - "test": "vendor/bin/phpunit" - }, "config": { "preferred-install": "dist" }, diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php deleted file mode 100644 index cda78c4..0000000 --- a/tests/CreatesApplication.php +++ /dev/null @@ -1,18 +0,0 @@ - Date: Mon, 29 Jun 2020 15:29:02 +0200 Subject: [PATCH 09/21] [GF] Fix test --- tests/ProjectsTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index 2d6be69..e1e4fd7 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -26,7 +26,7 @@ public function test_projects_list() $client = $this->getClient($response); $projects = $client->teams('john_doe')->projects()->list(); - $this->assertCount(9, $projects); + $this->assertCount(9, $projects['values']); } public function test_project_show() @@ -34,7 +34,7 @@ public function test_project_show() $response = new ProjectsShowResponse(); $client = $this->getClient($response); $project = $client->teams('john_doe')->projects()->show('Atlassian1'); - + $this->assertCount(11, $project); } From 499a83be39ed9566f147e53511245e97bed44d35 Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 15:32:52 +0200 Subject: [PATCH 10/21] [NS] remove docs --- docs/Bitbucket/Api/Workspaces.html | 1026 ------------------------- docs/Bitbucket/Api/WorkspacesOld.html | 310 -------- 2 files changed, 1336 deletions(-) delete mode 100644 docs/Bitbucket/Api/Workspaces.html delete mode 100644 docs/Bitbucket/Api/WorkspacesOld.html diff --git a/docs/Bitbucket/Api/Workspaces.html b/docs/Bitbucket/Api/Workspaces.html deleted file mode 100644 index 0c755b8..0000000 --- a/docs/Bitbucket/Api/Workspaces.html +++ /dev/null @@ -1,1026 +0,0 @@ - - - - - - Bitbucket\Api\Workspaces | Bitbucket API Client - - - - - - - - - - - - - - - - -
-
-
- -
- - -
-
- -
- -
-
- - -
- -
-
- - - -

class - Workspaces extends AbstractApi (View source) -

- - - - -
-

The Workspaces api class.

- - - - -

Methods

- -
-
-
- void -
-
- __construct(HttpMethodsClient $client) - -

Create a new api instance.

- -
-
-
- int|null -
-
- getPerPage() - -

Get the number of values to fetch per page.

- -
-
-
- void -
-
- setPerPage(int $perPage = null) - -

Set the number of values to fetch per page.

- -
-
-
- HttpMethodsClient -
-
- getHttpClient() - -

Get the http methods client.

- -
-
-
- array -
-
- get(string $path, array $params = [], array $headers = []) - -

Send a GET request with query params.

- -
-
-
- ResponseInterface -
-
- pureGet(string $path, array $params = [], array $headers = []) - -

Send a GET request with query params.

- -
-
-
- array -
-
- post(string $path, array $params = [], array $headers = []) - -

Send a POST request with JSON-encoded params.

- -
-
-
- array -
-
- postRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) - -

Send a POST request with raw data.

- -
-
-
- array -
-
- put(string $path, array $params = [], array $headers = []) - -

Send a PUT request with JSON-encoded params.

- -
-
-
- array -
-
- putRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) - -

Send a PUT request with raw data.

- -
-
-
- array -
-
- delete(string $path, array $params = [], array $headers = []) - -

Send a DELETE request with JSON-encoded params.

- -
-
-
- array -
-
- deleteRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) - -

Send a DELETE request with raw data.

- -
-
-
- static string -
-
- buildPath(string ...$parts) - -

Build a URL path from the given parts.

- -
-
-
- array -
-
- list(array $params = []) - -

No description

-
-
-
-
-
- string -
-
- buildWorkspacesPath(string ...$parts) - -

Build the workspaces path from the given parts.

-
-
-
- - -

Details

- -
-
-

- - void - __construct(HttpMethodsClient $client) - -

-
- - - -
-

Create a new api instance.

-
-

Parameters

- - - - - - - -
HttpMethodsClient$client
- - -

Return Value

- - - - - - -
void
- - - -
-
- -
-
-

- - int|null - getPerPage() - -

-
- - - -
-

Get the number of values to fetch per page.

-
- -

Return Value

- - - - - - -
int|null
- - - -
-
- -
-
-

- - void - setPerPage(int $perPage = null) - -

-
- - - -
-

Set the number of values to fetch per page.

-
-

Parameters

- - - - - - - -
int$perPage
- - -

Return Value

- - - - - - -
void
- - - -
-
- -
-
-

- - protected HttpMethodsClient - getHttpClient() - -

-
- - - -
-

Get the http methods client.

-
- -

Return Value

- - - - - - -
HttpMethodsClient
- - - -
-
- -
-
-

- - protected array - get(string $path, array $params = [], array $headers = []) - -

-
- - - -
-

Send a GET request with query params.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
array$params
array$headers
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - protected ResponseInterface - pureGet(string $path, array $params = [], array $headers = []) - -

-
- - - -
-

Send a GET request with query params.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
array$params
array$headers
- - -

Return Value

- - - - - - -
ResponseInterface
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - protected array - post(string $path, array $params = [], array $headers = []) - -

-
- - - -
-

Send a POST request with JSON-encoded params.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
array$params
array$headers
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - protected array - postRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) - -

-
- - - -
-

Send a POST request with raw data.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
string|StreamInterface|null$body
array$headers
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - protected array - put(string $path, array $params = [], array $headers = []) - -

-
- - - -
-

Send a PUT request with JSON-encoded params.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
array$params
array$headers
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - protected array - putRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) - -

-
- - - -
-

Send a PUT request with raw data.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
string|StreamInterface|null$body
array$headers
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - protected array - delete(string $path, array $params = [], array $headers = []) - -

-
- - - -
-

Send a DELETE request with JSON-encoded params.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
array$params
array$headers
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - protected array - deleteRaw(string $path, string|StreamInterface|null $body = null, array $headers = []) - -

-
- - - -
-

Send a DELETE request with raw data.

-
-

Parameters

- - - - - - - - - - - - - - - - - -
string$path
string|StreamInterface|null$body
array$headers
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
-

- - static protected string - buildPath(string ...$parts) - -

-
- - - -
-

Build a URL path from the given parts.

-
-

Parameters

- - - - - - - -
string...$parts
- - -

Return Value

- - - - - - -
string
- - -

Exceptions

- - - - - - -
InvalidArgumentException
- - -
-
- -
-
-

- - array - list(array $params = []) - -

-
- - - -
-

Parameters

- - - - - - - -
array$params
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
-
- -
-
-

- - protected string - buildWorkspacesPath(string ...$parts) - -

-
- - - -
-

Build the workspaces path from the given parts.

-
-

Parameters

- - - - - - - -
string...$parts
- - -

Return Value

- - - - - - -
string
- - -

Exceptions

- - - - - - -
InvalidArgumentException
- - -
-
- -
-
- - -
- - -
-
- - - diff --git a/docs/Bitbucket/Api/WorkspacesOld.html b/docs/Bitbucket/Api/WorkspacesOld.html deleted file mode 100644 index 85190b1..0000000 --- a/docs/Bitbucket/Api/WorkspacesOld.html +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - Bitbucket\Api\Repositories | Bitbucket API Client - - - - - - - - - - - - - - - - -
-
-
- -
- - -
-
- -
- -
-
- - -
- -
-
- - - -

class - Workspaces extends AbstractApi (View source) -

- - - - -
-

The workspaces api class.

- - - - -

Methods

- -
-
-
- void -
-
- __construct(HttpMethodsClient $client) - -

Create a new api instance.

- -
-
-
- int|null -
-
- getPerPage() - -

Get the number of values to fetch per page.

- -
-
-
- void -
-
- setPerPage(int $perPage = null) - -

Set the number of values to fetch per page.

- -
-
-
- array -
-
- list(array $params = []) - -

No description

-
-
-
- -

Details

- -
-
-

- - void - __construct(HttpMethodsClient $client) - -

-
- - - -
-

Create a new api instance.

-
-

Parameters

- - - - - - - -
HttpMethodsClient$client
- - -

Return Value

- - - - - - -
void
- - - -
-
- -
-
-

- - int|null - getPerPage() - -

-
- - - -
-

Get the number of values to fetch per page.

-
- -

Return Value

- - - - - - -
int|null
- - - -
-
- -
-
-

- - void - setPerPage(int $perPage = null) - -

-
- - - -
-

Set the number of values to fetch per page.

-
-

Parameters

- - - - - - - -
int$perPage
- - -

Return Value

- - - - - - -
void
- - - -
-
- -
-
-

- - array - list(array $params = []) - -

-
- - - -
-

Parameters

- - - - - - - -
array$params
- - -

Return Value

- - - - - - -
array
- - -

Exceptions

- - - - - - -
Exception
- - -
-
- -
- - -
- - -
-
- - - From 09538e68b9cc03a65029572dc1e78f9e40925ae0 Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 15:33:07 +0200 Subject: [PATCH 11/21] [NS] fix and update tests --- tests/ProjectsTest.php | 2 +- tests/responses/ProjectsListResponse.php | 2 +- tests/stubs/projects-list-success.json | 812 +++++++++++------------ 3 files changed, 408 insertions(+), 408 deletions(-) diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index 2d6be69..d0d3cdd 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -26,7 +26,7 @@ public function test_projects_list() $client = $this->getClient($response); $projects = $client->teams('john_doe')->projects()->list(); - $this->assertCount(9, $projects); + $this->assertCount(9, $projects['values']); } public function test_project_show() diff --git a/tests/responses/ProjectsListResponse.php b/tests/responses/ProjectsListResponse.php index 011b9db..333a523 100644 --- a/tests/responses/ProjectsListResponse.php +++ b/tests/responses/ProjectsListResponse.php @@ -19,6 +19,6 @@ class ProjectsListResponse extends BaseResponse implements ResponseFactory public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') { $json = $this->getJsonContent('stubs/projects-list-success.json'); - return new Response($statusCode, ['Content-Type' => 'application/json'], $json); + return new Response(200, ['Content-Type' => 'application/json'], $json); } } diff --git a/tests/stubs/projects-list-success.json b/tests/stubs/projects-list-success.json index 5db6534..5d1c7df 100644 --- a/tests/stubs/projects-list-success.json +++ b/tests/stubs/projects-list-success.json @@ -1,527 +1,527 @@ { - "pagelen":50, + "pagelen":10, "values":[ { - "description":"", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/APPIZZA" + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian1" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/APPIZZA" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian1" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"APPIZZA\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian1\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/APPIZZA\/avatar\/32?ts=1592993838" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian1/avatar/32?ts=1592993838" } }, - "uuid":"{f38daeea-d64f-44f7-afc8-f972d09b1d08}", - "created_on":"2020-06-24T10:17:18.875720+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{f38daeea-d64f-44f7-afc8-f972d09b1d08}", + "created_on": "2020-06-24T10:17:18.875720+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"APPIZZA", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian1", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2020-06-24T10:17:18.875739+00:00", - "type":"project", - "is_private":true, - "name":"Appizzachepizza" + "updated_on": "2020-06-24T10:17:18.875739+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian1" }, { - "description":null, - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/NEIG" + "description": null, + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian2" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/NEIG" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian2" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"NEIG\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian2\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/NEIG\/avatar\/32?ts=1589292488" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian2/avatar/32?ts=1589292488" } }, - "uuid":"{320ae6b5-04a2-495e-8ef2-642cd50817ba}", - "created_on":"2020-05-12T14:08:08.062102+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{320ae6b5-04a2-495e-8ef2-642cd50817ba}", + "created_on": "2020-05-12T14:08:08.062102+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"NEIG", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian2", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2020-05-12T14:08:08.062141+00:00", - "type":"project", - "is_private":false, - "name":"neighborhood" + "updated_on": "2020-05-12T14:08:08.062141+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian2" }, { - "description":null, - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/UN" + "description": null, + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian3" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/UN" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian3" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"UN\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian3\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/UN\/avatar\/32?ts=1588922476" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian3/avatar/32?ts=1588922476" } }, - "uuid":"{fa26f90b-26bb-4ce5-9253-1ba44c5307df}", - "created_on":"2020-05-08T07:21:16.638095+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{fa26f90b-26bb-4ce5-9253-1ba44c5307df}", + "created_on": "2020-05-08T07:21:16.638095+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"UN", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian3", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2020-05-08T07:21:16.638109+00:00", - "type":"project", - "is_private":false, - "name":"uncode" + "updated_on": "2020-05-08T07:21:16.638109+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian3" }, { - "description":"", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/SPEAK" + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian4" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/SPEAK" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian4" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"SPEAK\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian4\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/SPEAK\/avatar\/32?ts=1582298430" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian4/avatar/32?ts=1582298430" } }, - "uuid":"{6a489fd0-08a4-4915-9e64-4add52c0b1e6}", - "created_on":"2020-02-21T15:19:50.594200+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{6a489fd0-08a4-4915-9e64-4add52c0b1e6}", + "created_on": "2020-02-21T15:19:50.594200+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"SPEAK", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian4", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2020-02-21T15:20:30.301162+00:00", - "type":"project", - "is_private":false, - "name":"speak-out" + "updated_on": "2020-02-21T15:20:30.301162+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian4" }, { - "description":"", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/ATS" + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian5" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/ATS" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian5" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"ATS\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian5\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/ATS\/avatar\/32?ts=1580310154" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian5/avatar/32?ts=1580310154" } }, - "uuid":"{a04d2b8e-04b5-4dbb-abad-a10517d9f418}", - "created_on":"2020-01-29T15:02:34.818938+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{a04d2b8e-04b5-4dbb-abad-a10517d9f418}", + "created_on": "2020-01-29T15:02:34.818938+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"ATS", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian5", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2020-01-29T15:02:34.818955+00:00", - "type":"project", - "is_private":true, - "name":"ATS" + "updated_on": "2020-01-29T15:02:34.818955+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian5" }, { - "description":"", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/PENTA" + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian6" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/PENTA" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian6" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"PENTA\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian6\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/PENTA\/avatar\/32?ts=1574078583" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian6/avatar/32?ts=1574078583" } }, - "uuid":"{81f98281-973f-4cf2-a6a9-8a31e3872211}", - "created_on":"2019-11-18T11:59:29.084414+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{81f98281-973f-4cf2-a6a9-8a31e3872211}", + "created_on": "2019-11-18T11:59:29.084414+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"PENTA", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian6", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2019-11-18T12:03:03.696455+00:00", - "type":"project", - "is_private":true, - "name":"Pentaidinnovation" + "updated_on": "2019-11-18T12:03:03.696455+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian6" }, { - "description":"", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/ESTE" + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian7" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/ESTE" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian7" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"ESTE\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian7\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/ESTE\/avatar\/32?ts=1593011466" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian7/avatar/32?ts=1593011466" } }, - "uuid":"{95d40011-a2ef-4e27-ba05-899e0fa9b3bd}", - "created_on":"2019-11-06T14:25:50.773844+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{95d40011-a2ef-4e27-ba05-899e0fa9b3bd}", + "created_on": "2019-11-06T14:25:50.773844+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"ESTE", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian7", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2020-06-24T15:11:06.066911+00:00", - "type":"project", - "is_private":false, - "name":"Estensione" + "updated_on": "2020-06-24T15:11:06.066911+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian7" }, { - "description":null, - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/OA" + "description": null, + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian8" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/OA" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian8" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"OA\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian8\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/OA\/avatar\/32?ts=1572018611" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian8/avatar/32?ts=1572018611" } }, - "uuid":"{07be1185-daff-4879-b75e-9f9d1a10fcb1}", - "created_on":"2019-10-25T15:50:11.938768+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{07be1185-daff-4879-b75e-9f9d1a10fcb1}", + "created_on": "2019-10-25T15:50:11.938768+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"OA", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian8", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2019-10-25T15:50:11.938787+00:00", - "type":"project", - "is_private":false, - "name":"Offline Agency" + "updated_on": "2019-10-25T15:50:11.938787+00:00", + "type": "project", + "is_private": false, + "name": "Atlassian8" }, { - "description":"", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency\/projects\/MC" + "description": "", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe/projects/Atlassian9" }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/workspace\/projects\/MC" + "html": { + "href": "https://bitbucket.org/john_doe/workspace/projects/Atlassian9" }, - "repositories":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/offlineagency?q=project.key=\"MC\"" + "repositories": { + "href": "https://api.bitbucket.org/2.0/repositories/john_doe?q=project.key=\"Atlassian9\"" }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/user\/offlineagency\/projects\/MC\/avatar\/32?ts=1571998444" + "avatar": { + "href": "https://bitbucket.org/account/user/john_doe/projects/Atlassian9/avatar/32?ts=1571998444" } }, - "uuid":"{9b15c9a7-6d6f-4639-ae23-c86307e19a89}", - "created_on":"2019-10-25T10:14:04.450212+00:00", - "workspace":{ - "slug":"offlineagency", - "type":"workspace", - "name":"offline-agency", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/workspaces\/offlineagency" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/offlineagency\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/workspaces\/offlineagency\/avatar\/?ts=1571998380" + "uuid": "{9b15c9a7-6d6f-4639-ae23-c86307e19a89}", + "created_on": "2019-10-25T10:14:04.450212+00:00", + "workspace": { + "slug": "john_doe", + "type": "workspace", + "name": "john-doe", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/workspaces/john_doe" + }, + "html": { + "href": "https://bitbucket.org/john_doe/" + }, + "avatar": { + "href": "https://bitbucket.org/workspaces/john_doe/avatar/?ts=1571998380" } }, - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}" + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}" }, - "key":"MC", - "owner":{ - "username":"offlineagency", - "display_name":"offline-agency", - "type":"team", - "uuid":"{eaf34f99-08d3-4888-ac79-b806e8927edd}", - "links":{ - "self":{ - "href":"https:\/\/api.bitbucket.org\/2.0\/teams\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" - }, - "html":{ - "href":"https:\/\/bitbucket.org\/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D\/" - }, - "avatar":{ - "href":"https:\/\/bitbucket.org\/account\/offlineagency\/avatar\/" + "key": "Atlassian9", + "owner": { + "username": "john_doe", + "display_name": "john-doe", + "type": "team", + "uuid": "{eaf34f99-08d3-4888-ac79-b806e8927edd}", + "links": { + "self": { + "href": "https://api.bitbucket.org/2.0/teams/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D" + }, + "html": { + "href": "https://bitbucket.org/%7Beaf34f99-08d3-4888-ac79-b806e8927edd%7D/" + }, + "avatar": { + "href": "https://bitbucket.org/account/john_doe/avatar/" } } }, - "updated_on":"2019-10-25T10:14:04.450232+00:00", - "type":"project", - "is_private":true, - "name":"Mariangela Caforio" + "updated_on": "2019-10-25T10:14:04.450232+00:00", + "type": "project", + "is_private": true, + "name": "Atlassian9" } ], "page":1, From bc0a1e07b9a57277215e0a1bb7834d1b03743ea7 Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 16:05:50 +0200 Subject: [PATCH 12/21] [NS] revert last change --- src/Api/Repositories/Workspaces.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Api/Repositories/Workspaces.php b/src/Api/Repositories/Workspaces.php index c992dfe..0752dab 100644 --- a/src/Api/Repositories/Workspaces.php +++ b/src/Api/Repositories/Workspaces.php @@ -34,24 +34,14 @@ public function repositories(string $repo) /** * @param string $repo - * @param $scm - * @param $project_key - * @param $is_private + * @param array $params * * @return array * * @throws \Http\Client\Exception */ - public function createRepository(string $repo, $scm, $project_key, $is_private) + public function createRepository(string $repo, array $params = []) { - $params = [ - 'scm' => $scm, - 'project' => (object)[ - 'key' => $project_key - ], - 'is_private' => $is_private - ]; - $path = $this->buildRepositoriesPath($repo).static::URI_SEPARATOR; return $this->post($path, $params); From 3b0079edb08f236108fab5b9f47d87ed1c33427b Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 16:06:06 +0200 Subject: [PATCH 13/21] [NS] use interface --- src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php index ae4e14f..f80ab2a 100644 --- a/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php +++ b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php @@ -15,6 +15,7 @@ use Bitbucket\Api\Repositories\AbstractRepositoriesApi; use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract users api class. @@ -33,11 +34,11 @@ abstract class AbstractWorkspacesApi extends AbstractRepositoriesApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client + * @param \Http\Client\Common\HttpMethodsClientInterface $client * @param string $username * @param string $repo */ - public function __construct(HttpMethodsClient $client, string $username, string $repo) + public function __construct(HttpMethodsClientInterface $client, string $username, string $repo) { parent::__construct($client, $username); $this->repo = $repo; From d166b8df8e504b7bc1e5c9555ee62224beaafe17 Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 16:06:27 +0200 Subject: [PATCH 14/21] [NS] revert last change --- src/Api/Teams/Projects.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index 99842ee..be01dc7 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -57,29 +57,13 @@ public function all() } /** - * @param string $name - * @param string $key - * @param string $description - * @param string $links - * @param bool $is_private + * @param array $params * * @return array * @throws Exception */ - public function create(string $name, string $key, string $description, string $links, bool $is_private) + public function create(array $params = []) { - $params = [ - 'name' => $name, - 'key' => $key, - 'description' => $description, - 'links' => (object)[ - 'avatar' => (object)[ - 'href' => $links - ] - ], - 'is_private' => $is_private - ]; - $path = $this->buildProjectsPath().static::URI_SEPARATOR; return $this->post($path, $params); From fce732abf762d106a0e3a7295713a113f35f3430 Mon Sep 17 00:00:00 2001 From: Nicolas Sanavia Date: Mon, 29 Jun 2020 16:16:50 +0200 Subject: [PATCH 15/21] [NS] fix update on teams/projects + fix projects tests --- src/Api/Teams/Projects.php | 20 ++------------------ tests/ProjectsTest.php | 37 +++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index be01dc7..bcc0c52 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -86,30 +86,14 @@ public function show(string $project, array $params = []) /** * @param string $project - * @param string $name - * @param string $key - * @param string $description - * @param string $links - * @param bool $is_private + * @param array $params * * @throws Exception * * @return array */ - public function update(string $project, string $name, string $key, string $description, string $links, bool $is_private) + public function update(string $project, array $params) { - $params = [ - 'name' => $name, - 'key' => $key, - 'description' => $description, - 'links' => (object)[ - 'avatar' => (object)[ - 'href' => $links - ] - ], - 'is_private' => $is_private - ]; - $path = $this->buildProjectsPath($project); return $this->put($path, $params); diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index e1e4fd7..84d5fc0 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -42,12 +42,21 @@ public function test_project_create() { $response = new ProjectCreateResponse(); $client = $this->getClient($response); + + $params = [ + 'name' => 'name', + 'key' => 'key', + 'description' => 'description', + 'links' => (object)[ + 'avatar' => (object)[ + 'href' => '' + ] + ], + 'is_private' => true, + ]; + $project = $client->teams('john_doe')->projects()->create( - 'name', - 'key', - 'description', - 'links', - true + $params ); $this->assertCount(11, $project); @@ -58,13 +67,21 @@ public function test_project_update() $response = new ProjectUpdateResponse(); $client = $this->getClient($response); + $params = [ + 'name' => 'name-updated', + 'key' => 'Atlassian1', + 'description' => 'description-updated', + 'links' => (object)[ + 'avatar' => (object)[ + 'href' => '' + ] + ], + 'is_private' => true, + ]; + $project = $client->teams('john_doe')->projects()->update( 'Atlassian1', - 'name-updated', - 'Atlassian1', - 'description-updated', - '', - true + $params ); $this->assertCount(11, $project); From f985d661f3ab309fe3bba7f6b41642298407b62b Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 15:55:39 +0000 Subject: [PATCH 16/21] Apply fixes from StyleCI --- src/Api/AbstractApi.php | 7 ++--- src/Api/Repositories/Workspaces.php | 13 ++++++---- .../Workspaces/AbstractWorkspacesApi.php | 5 ++-- .../Repositories/Workspaces/Repositories.php | 3 +-- src/Api/Teams/Projects.php | 6 ++--- src/Api/Teams/Repositories.php | 1 - src/Api/Workspaces.php | 8 +++--- tests/ProjectsTest.php | 26 +++++++++---------- tests/TestCase.php | 2 ++ tests/responses/BaseResponse.php | 4 +-- tests/responses/ProjectCreateResponse.php | 13 +++++----- tests/responses/ProjectRemoveResponse.php | 13 +++++----- tests/responses/ProjectUpdateResponse.php | 13 +++++----- tests/responses/ProjectsAllResponse.php | 13 +++++----- tests/responses/ProjectsListResponse.php | 10 ++++--- tests/responses/ProjectsShowResponse.php | 10 ++++--- tests/responses/WorkspacesAllResponse.php | 10 ++++--- tests/responses/WorkspacesListResponse.php | 10 ++++--- tests/responses/WorkspacesShowResponse.php | 10 ++++--- 19 files changed, 97 insertions(+), 80 deletions(-) diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index f2138fe..eba8ff3 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -136,11 +136,12 @@ protected function pureGet(string $path, array $params = [], array $headers = [] * Send a POST request with JSON-encoded params. * * @param string $path - * @param array $params - * @param array $headers + * @param array $params + * @param array $headers * - * @return array * @throws \Http\Client\Exception + * + * @return array */ protected function post(string $path, array $params = [], array $headers = []) { diff --git a/src/Api/Repositories/Workspaces.php b/src/Api/Repositories/Workspaces.php index 0752dab..03e7b78 100644 --- a/src/Api/Repositories/Workspaces.php +++ b/src/Api/Repositories/Workspaces.php @@ -34,11 +34,11 @@ public function repositories(string $repo) /** * @param string $repo - * @param array $params - * - * @return array + * @param array $params * * @throws \Http\Client\Exception + * + * @return array */ public function createRepository(string $repo, array $params = []) { @@ -49,9 +49,11 @@ public function createRepository(string $repo, array $params = []) /** * @param string $repo - * @param array $params - * @return array + * @param array $params + * * @throws \Http\Client\Exception + * + * @return array */ public function showRepositories(string $repo, array $params = []) { @@ -62,6 +64,7 @@ public function showRepositories(string $repo, array $params = []) /** * @param string ...$parts + * * @return string */ protected function buildRepositoriesPath(string ...$parts) diff --git a/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php index f80ab2a..4ce7b1e 100644 --- a/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php +++ b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php @@ -14,7 +14,6 @@ namespace Bitbucket\Api\Repositories\Workspaces; use Bitbucket\Api\Repositories\AbstractRepositoriesApi; -use Http\Client\Common\HttpMethodsClient; use Http\Client\Common\HttpMethodsClientInterface; /** @@ -35,8 +34,8 @@ abstract class AbstractWorkspacesApi extends AbstractRepositoriesApi * Create a new api instance. * * @param \Http\Client\Common\HttpMethodsClientInterface $client - * @param string $username - * @param string $repo + * @param string $username + * @param string $repo */ public function __construct(HttpMethodsClientInterface $client, string $username, string $repo) { diff --git a/src/Api/Repositories/Workspaces/Repositories.php b/src/Api/Repositories/Workspaces/Repositories.php index 24feb11..3cf82f5 100644 --- a/src/Api/Repositories/Workspaces/Repositories.php +++ b/src/Api/Repositories/Workspaces/Repositories.php @@ -20,7 +20,6 @@ */ class Repositories extends AbstractWorkspacesApi { - /** * @param string $repo * @param array $params @@ -49,4 +48,4 @@ protected function buildRepositoryPath(string ...$parts) { return static::buildPath('repositories', $this->username, ...$parts); } -} \ No newline at end of file +} diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index bcc0c52..eee621e 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -37,7 +37,6 @@ public function list(array $params = []) } /** - * * @throws Exception * * @return array @@ -59,8 +58,9 @@ public function all() /** * @param array $params * - * @return array * @throws Exception + * + * @return array */ public function create(array $params = []) { @@ -86,7 +86,7 @@ public function show(string $project, array $params = []) /** * @param string $project - * @param array $params + * @param array $params * * @throws Exception * diff --git a/src/Api/Teams/Repositories.php b/src/Api/Teams/Repositories.php index b29f05e..f8f865e 100644 --- a/src/Api/Teams/Repositories.php +++ b/src/Api/Teams/Repositories.php @@ -35,7 +35,6 @@ public function list(array $params = []) } /** - * * @throws \Http\Client\Exception * * @return array diff --git a/src/Api/Workspaces.php b/src/Api/Workspaces.php index cc579b6..02e329b 100644 --- a/src/Api/Workspaces.php +++ b/src/Api/Workspaces.php @@ -45,11 +45,11 @@ public function all() /** * @param string $workspace - * @param array $params - * - * @return array + * @param array $params * * @throws \Http\Client\Exception + * + * @return array */ public function show(string $workspace, array $params = []) { @@ -71,4 +71,4 @@ protected function buildWorkspacePath(string ...$parts) { return static::buildPath('workspaces', ...$parts); } -} \ No newline at end of file +} diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index 84d5fc0..dd471da 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -34,7 +34,7 @@ public function test_project_show() $response = new ProjectsShowResponse(); $client = $this->getClient($response); $project = $client->teams('john_doe')->projects()->show('Atlassian1'); - + $this->assertCount(11, $project); } @@ -44,13 +44,13 @@ public function test_project_create() $client = $this->getClient($response); $params = [ - 'name' => 'name', - 'key' => 'key', + 'name' => 'name', + 'key' => 'key', 'description' => 'description', - 'links' => (object)[ - 'avatar' => (object)[ - 'href' => '' - ] + 'links' => (object) [ + 'avatar' => (object) [ + 'href' => '', + ], ], 'is_private' => true, ]; @@ -68,13 +68,13 @@ public function test_project_update() $client = $this->getClient($response); $params = [ - 'name' => 'name-updated', - 'key' => 'Atlassian1', + 'name' => 'name-updated', + 'key' => 'Atlassian1', 'description' => 'description-updated', - 'links' => (object)[ - 'avatar' => (object)[ - 'href' => '' - ] + 'links' => (object) [ + 'avatar' => (object) [ + 'href' => '', + ], ], 'is_private' => true, ]; diff --git a/tests/TestCase.php b/tests/TestCase.php index 8e4197a..60afadd 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -12,12 +12,14 @@ abstract class TestCase extends BaseTestCase { /** * @param BaseResponse $response + * * @return Client */ protected function getClient(BaseResponse $response) { $mock_client = new MockClient($response); $builder = new Builder($mock_client); + return new Client($builder); } } diff --git a/tests/responses/BaseResponse.php b/tests/responses/BaseResponse.php index 0d9f4a9..6c9564e 100644 --- a/tests/responses/BaseResponse.php +++ b/tests/responses/BaseResponse.php @@ -1,13 +1,12 @@ getJsonContent('stubs/project-create-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } -} \ No newline at end of file +} diff --git a/tests/responses/ProjectRemoveResponse.php b/tests/responses/ProjectRemoveResponse.php index 876feb0..c488fd4 100644 --- a/tests/responses/ProjectRemoveResponse.php +++ b/tests/responses/ProjectRemoveResponse.php @@ -1,6 +1,5 @@ getJsonContent('stubs/project-remove-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } -} \ No newline at end of file +} diff --git a/tests/responses/ProjectUpdateResponse.php b/tests/responses/ProjectUpdateResponse.php index fee9017..9981a8c 100644 --- a/tests/responses/ProjectUpdateResponse.php +++ b/tests/responses/ProjectUpdateResponse.php @@ -1,6 +1,5 @@ getJsonContent('stubs/project-update-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } -} \ No newline at end of file +} diff --git a/tests/responses/ProjectsAllResponse.php b/tests/responses/ProjectsAllResponse.php index 5d80aec..2fc02f9 100644 --- a/tests/responses/ProjectsAllResponse.php +++ b/tests/responses/ProjectsAllResponse.php @@ -1,6 +1,5 @@ getJsonContent('stubs/projects-all-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } -} \ No newline at end of file +} diff --git a/tests/responses/ProjectsListResponse.php b/tests/responses/ProjectsListResponse.php index 333a523..74b7324 100644 --- a/tests/responses/ProjectsListResponse.php +++ b/tests/responses/ProjectsListResponse.php @@ -9,16 +9,18 @@ class ProjectsListResponse extends BaseResponse implements ResponseFactory { /** - * @param int $statusCode - * @param null $reasonPhrase - * @param array $headers - * @param null $body + * @param int $statusCode + * @param null $reasonPhrase + * @param array $headers + * @param null $body * @param string $protocolVersion + * * @return Response|ResponseInterface */ public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') { $json = $this->getJsonContent('stubs/projects-list-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } } diff --git a/tests/responses/ProjectsShowResponse.php b/tests/responses/ProjectsShowResponse.php index dfb468f..a5a117b 100644 --- a/tests/responses/ProjectsShowResponse.php +++ b/tests/responses/ProjectsShowResponse.php @@ -9,16 +9,18 @@ class ProjectsShowResponse extends BaseResponse implements ResponseFactory { /** - * @param int $statusCode - * @param null $reasonPhrase - * @param array $headers - * @param null $body + * @param int $statusCode + * @param null $reasonPhrase + * @param array $headers + * @param null $body * @param string $protocolVersion + * * @return Response|ResponseInterface */ public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') { $json = $this->getJsonContent('stubs/projects-show-success.json'); + return new Response($statusCode, ['Content-Type' => 'application/json'], $json); } } diff --git a/tests/responses/WorkspacesAllResponse.php b/tests/responses/WorkspacesAllResponse.php index 77ce44a..02ec362 100644 --- a/tests/responses/WorkspacesAllResponse.php +++ b/tests/responses/WorkspacesAllResponse.php @@ -9,16 +9,18 @@ class WorkspacesAllResponse extends BaseResponse implements ResponseFactory { /** - * @param int $statusCode - * @param null $reasonPhrase - * @param array $headers - * @param null $body + * @param int $statusCode + * @param null $reasonPhrase + * @param array $headers + * @param null $body * @param string $protocolVersion + * * @return Response|ResponseInterface */ public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') { $json = $this->getJsonContent('stubs/workspaces-all-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } } diff --git a/tests/responses/WorkspacesListResponse.php b/tests/responses/WorkspacesListResponse.php index 4fb65e0..08d07fd 100644 --- a/tests/responses/WorkspacesListResponse.php +++ b/tests/responses/WorkspacesListResponse.php @@ -9,16 +9,18 @@ class WorkspacesListResponse extends BaseResponse implements ResponseFactory { /** - * @param int $statusCode - * @param null $reasonPhrase - * @param array $headers - * @param null $body + * @param int $statusCode + * @param null $reasonPhrase + * @param array $headers + * @param null $body * @param string $protocolVersion + * * @return Response|ResponseInterface */ public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') { $json = $this->getJsonContent('stubs/workspaces-list-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } } diff --git a/tests/responses/WorkspacesShowResponse.php b/tests/responses/WorkspacesShowResponse.php index b9ed15c..d759ced 100644 --- a/tests/responses/WorkspacesShowResponse.php +++ b/tests/responses/WorkspacesShowResponse.php @@ -9,16 +9,18 @@ class WorkspacesShowResponse extends BaseResponse implements ResponseFactory { /** - * @param int $statusCode - * @param null $reasonPhrase - * @param array $headers - * @param null $body + * @param int $statusCode + * @param null $reasonPhrase + * @param array $headers + * @param null $body * @param string $protocolVersion + * * @return Response|ResponseInterface */ public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') { $json = $this->getJsonContent('stubs/workspaces-show-success.json'); + return new Response(200, ['Content-Type' => 'application/json'], $json); } } From a65d01367316bea7a42fed58ec88986c6e09922f Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 18:57:50 +0200 Subject: [PATCH 17/21] [GF] Fix requested changes --- composer.json | 5 ----- src/Api/Teams/Projects.php | 2 +- tests/responses/BaseResponse.php | 6 ++---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index fa7027a..d6a9365 100644 --- a/composer.json +++ b/composer.json @@ -39,11 +39,6 @@ "config": { "preferred-install": "dist" }, - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, "minimum-stability": "dev", "prefer-stable": true } diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index eee621e..1a751aa 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -25,7 +25,7 @@ class Projects extends AbstractTeamsApi /** * @param array $params * - * @throws Exception + * @throws \Http\Client\Exception * * @return array */ diff --git a/tests/responses/BaseResponse.php b/tests/responses/BaseResponse.php index 6c9564e..b911003 100644 --- a/tests/responses/BaseResponse.php +++ b/tests/responses/BaseResponse.php @@ -5,18 +5,16 @@ class BaseResponse { /** - * @param $path - * + * @param string $path * @return string */ - protected function packagePath($path) + protected function packagePath(string $path) { return __DIR__.'/../'.$path; } /** * @param string $path - * * @return false|string */ protected function getJsonContent(string $path) From 8dae0a0566148e50d51cdfcf1e98f17031aa1e29 Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Mon, 29 Jun 2020 17:05:30 +0000 Subject: [PATCH 18/21] Apply fixes from StyleCI --- tests/responses/BaseResponse.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/responses/BaseResponse.php b/tests/responses/BaseResponse.php index b911003..cdbb504 100644 --- a/tests/responses/BaseResponse.php +++ b/tests/responses/BaseResponse.php @@ -6,6 +6,7 @@ class BaseResponse { /** * @param string $path + * * @return string */ protected function packagePath(string $path) @@ -15,6 +16,7 @@ protected function packagePath(string $path) /** * @param string $path + * * @return false|string */ protected function getJsonContent(string $path) From ab45989430cc168351acb2ed50c703dd73a317f7 Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Tue, 30 Jun 2020 00:06:47 +0200 Subject: [PATCH 19/21] [GF] Fix import + moved dependencies to require-dev --- composer.json | 6 +++--- src/Api/Teams/Projects.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index d6a9365..1b1be72 100644 --- a/composer.json +++ b/composer.json @@ -18,13 +18,13 @@ "php-http/multipart-stream-builder": "^1.1", "psr/cache": "^1.0", "psr/http-client-implementation": "^1.0", - "psr/http-message": "^1.0", - "php-http/mock-client": "^1.3" + "psr/http-message": "^1.0" }, "require-dev": { "graham-campbell/analyzer": "^2.4", "phpunit/phpunit": "^8.5|^9.0", - "php-http/guzzle6-adapter": "^2.0" + "php-http/guzzle6-adapter": "^2.0", + "php-http/mock-client": "^1.3" }, "autoload": { "psr-4": { diff --git a/src/Api/Teams/Projects.php b/src/Api/Teams/Projects.php index 1a751aa..da46755 100644 --- a/src/Api/Teams/Projects.php +++ b/src/Api/Teams/Projects.php @@ -37,7 +37,7 @@ public function list(array $params = []) } /** - * @throws Exception + * @throws \Http\Client\Exception * * @return array */ @@ -58,7 +58,7 @@ public function all() /** * @param array $params * - * @throws Exception + * @throws \Http\Client\Exception * * @return array */ @@ -73,7 +73,7 @@ public function create(array $params = []) * @param string $project * @param array $params * - * @throws Exception + * @throws \Http\Client\Exception * * @return array */ @@ -88,7 +88,7 @@ public function show(string $project, array $params = []) * @param string $project * @param array $params * - * @throws Exception + * @throws \Http\Client\Exception * * @return array */ @@ -103,7 +103,7 @@ public function update(string $project, array $params) * @param string $project * @param array $params * - * @throws Exception + * @throws \Http\Client\Exception * * @return array */ From 2e91bd549056189de01d1108564a7b1a3e6a022d Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Tue, 30 Jun 2020 10:50:51 +0200 Subject: [PATCH 20/21] [GF] Update tests --- src/Api/Workspaces.php | 14 ++++++++++++++ src/Api/Workspaces/Projects.php | 21 +-------------------- src/Client.php | 8 -------- tests/ProjectsTest.php | 19 +++++-------------- tests/WorkspacesTest.php | 13 ++----------- 5 files changed, 22 insertions(+), 53 deletions(-) diff --git a/src/Api/Workspaces.php b/src/Api/Workspaces.php index 4af70bb..0fe6dcb 100644 --- a/src/Api/Workspaces.php +++ b/src/Api/Workspaces.php @@ -60,6 +60,20 @@ public function show(array $params = []) return $this->get($path, $params); } + /** + * @param array $params + * + * @throws \Http\Client\Exception + * + * @return array + */ + public function list(array $params = []) + { + $path = $this->buildWorkspacesPath(); + + return $this->get($path, $params); + } + /** * @param array $params * diff --git a/src/Api/Workspaces/Projects.php b/src/Api/Workspaces/Projects.php index d6cc198..4e6d998 100644 --- a/src/Api/Workspaces/Projects.php +++ b/src/Api/Workspaces/Projects.php @@ -36,25 +36,6 @@ public function list(array $params = []) return $this->get($path, $params); } - /** - * @throws \Http\Client\Exception - * - * @return array - */ - public function all() - { - $projects = []; - $page = 1; - - do { - $project = $this->list(['page' => $page]); - $projects = array_merge($projects, $project['values']); - $page++; - } while (isset($project['next'])); - - return $projects; - } - /** * @param array $params * @@ -125,6 +106,6 @@ public function remove(string $project, array $params = []) */ protected function buildProjectsPath(string ...$parts) { - return static::buildPath('workspaces', $this->username, 'projects', ...$parts); + return static::buildPath('workspaces', $this->workspace, 'projects', ...$parts); } } diff --git a/src/Client.php b/src/Client.php index 7b3d017..756357c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -138,14 +138,6 @@ public function repositories() return new Repositories($this->getHttpClient()); } - /** - * @return \Bitbucket\Api\Workspaces - */ - public function workspaces() - { - return new Workspaces($this->getHttpClient()); - } - /** * @return \Bitbucket\Api\Snippets */ diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index dd471da..b00419c 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -11,20 +11,11 @@ class ProjectsTest extends TestCase { - public function test_projects_all() - { - $response = new ProjectsAllResponse(); - $client = $this->getClient($response); - $projects = $client->teams('john_doe')->projects()->all(); - - $this->assertCount(11, $projects); - } - public function test_projects_list() { $response = new ProjectsListResponse(); $client = $this->getClient($response); - $projects = $client->teams('john_doe')->projects()->list(); + $projects = $client->workspaces('my-workspace')->projects()->list(); $this->assertCount(9, $projects['values']); } @@ -33,7 +24,7 @@ public function test_project_show() { $response = new ProjectsShowResponse(); $client = $this->getClient($response); - $project = $client->teams('john_doe')->projects()->show('Atlassian1'); + $project = $client->workspaces('my-workspace')->projects()->show('Atlassian1'); $this->assertCount(11, $project); } @@ -55,7 +46,7 @@ public function test_project_create() 'is_private' => true, ]; - $project = $client->teams('john_doe')->projects()->create( + $project = $client->workspaces('my-workspace')->projects()->create( $params ); @@ -79,7 +70,7 @@ public function test_project_update() 'is_private' => true, ]; - $project = $client->teams('john_doe')->projects()->update( + $project = $client->workspaces('my-workspace')->projects()->update( 'Atlassian1', $params ); @@ -92,7 +83,7 @@ public function test_project_remove() $response = new ProjectRemoveResponse(); $client = $this->getClient($response); - $project = $client->teams('john_doe')->projects()->remove( + $project = $client->workspaces('my-workspace')->projects()->remove( 'Atlassian1' ); diff --git a/tests/WorkspacesTest.php b/tests/WorkspacesTest.php index 146a5dd..08cc567 100644 --- a/tests/WorkspacesTest.php +++ b/tests/WorkspacesTest.php @@ -8,20 +8,11 @@ class WorkspacesTest extends TestCase { - public function test_workspaces_all() - { - $response = new WorkspacesAllResponse(); - $client = $this->getClient($response); - $workspaces = $client->workspaces()->all(); - - $this->assertCount(11, $workspaces); - } - public function test_workspaces_list() { $response = new WorkspacesListResponse(); $client = $this->getClient($response); - $workspaces = $client->workspaces()->list(); + $workspaces = $client->workspaces('my-workspace')->list(); $this->assertCount(4, $workspaces); } @@ -30,7 +21,7 @@ public function test_workspace_show() { $response = new WorkspacesShowResponse(); $client = $this->getClient($response); - $workspace = $client->workspaces()->show('john_doe'); + $workspace = $client->workspaces('my-workspace')->show(); $this->assertCount(7, $workspace); } From 7898d70b655b738a2970a048b80cddd172f36430 Mon Sep 17 00:00:00 2001 From: Giacomo Fabbian Date: Tue, 30 Jun 2020 08:56:00 +0000 Subject: [PATCH 21/21] Apply fixes from StyleCI --- src/Api/Workspaces/Projects.php | 2 -- tests/ProjectsTest.php | 1 - tests/WorkspacesTest.php | 1 - 3 files changed, 4 deletions(-) diff --git a/src/Api/Workspaces/Projects.php b/src/Api/Workspaces/Projects.php index 4e6d998..a48b50d 100644 --- a/src/Api/Workspaces/Projects.php +++ b/src/Api/Workspaces/Projects.php @@ -13,8 +13,6 @@ namespace Bitbucket\Api\Workspaces; -use Http\Client\Exception; - /** * The projects api class. * diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index b00419c..121145f 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -4,7 +4,6 @@ use Bitbucket\Tests\responses\ProjectCreateResponse; use Bitbucket\Tests\responses\ProjectRemoveResponse; -use Bitbucket\Tests\responses\ProjectsAllResponse; use Bitbucket\Tests\responses\ProjectsListResponse; use Bitbucket\Tests\responses\ProjectsShowResponse; use Bitbucket\Tests\responses\ProjectUpdateResponse; diff --git a/tests/WorkspacesTest.php b/tests/WorkspacesTest.php index 08cc567..ee46acc 100644 --- a/tests/WorkspacesTest.php +++ b/tests/WorkspacesTest.php @@ -2,7 +2,6 @@ namespace Bitbucket\Tests; -use Bitbucket\Tests\responses\WorkspacesAllResponse; use Bitbucket\Tests\responses\WorkspacesListResponse; use Bitbucket\Tests\responses\WorkspacesShowResponse;