1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00
appwrite/tests/e2e/Services/Teams/TeamsBaseClient.php

81 lines
2.7 KiB
PHP
Raw Normal View History

2020-01-17 03:06:28 +13:00
<?php
namespace Tests\E2E\Services\Teams;
use Tests\E2E\Client;
trait TeamsBaseClient
{
/**
* @depends testCreateTeam
*/
public function testGetTeamMembers($data):array
{
$uid = (isset($data['teamUid'])) ? $data['teamUid'] : '';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$uid.'/members', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body'][0]['$uid']);
$this->assertEquals($this->getUser()['$uid'], $response['body'][0]['$uid']);
$this->assertEquals($this->getUser()['name'], $response['body'][0]['name']);
$this->assertEquals($this->getUser()['email'], $response['body'][0]['email']);
$this->assertEquals('owner', $response['body'][0]['roles'][0]);
/**
* Test for FAILURE
*/
return [];
}
2020-01-19 09:02:47 +13:00
/**
* @depends testCreateTeam
*/
public function testCreateTeamMembership($data):array
{
$uid = (isset($data['teamUid'])) ? $data['teamUid'] : '';
$email = uniqid().'friend@localhost.test';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_POST, '/teams/'.$uid.'/memberships', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
], $this->getHeaders()), [
'email' => $email,
'name' => 'Friend User',
'roles' => ['admin', 'editor'],
'url' => 'http://localhost:5000/join-us#title'
]);
if ($response['headers']['status-code'] !== 201) {var_dump($response);}
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
$this->assertIsInt($response['body']['joined']);
$this->assertEquals(false, $response['body']['confirm']);
/**
* Test for FAILURE
*/
// $response = $this->client->call(Client::METHOD_POST, '/teams/'.$uid.'/memberships', array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$uid'],
// ], $this->getHeaders()));
// $this->assertEquals(404, $response['headers']['status-code']);
return [];
}
2020-01-17 03:06:28 +13:00
}