1
0
Fork 0
mirror of synced 2024-08-29 00:52:07 +12:00

feat: uncomment

This commit is contained in:
Christy Jacob 2021-05-11 23:30:00 +05:30
parent 5e6cc855c9
commit 0bd542077f

View file

@ -6,236 +6,236 @@ use Tests\E2E\Client;
trait TeamsBaseClient trait TeamsBaseClient
{ {
// /** /**
// * @depends testCreateTeam * @depends testCreateTeam
// */ */
// public function testGetTeamMemberships($data):array public function testGetTeamMemberships($data):array
// { {
// $teamUid = $data['teamUid'] ?? ''; $teamUid = $data['teamUid'] ?? '';
// /** /**
// * Test for SUCCESS * Test for SUCCESS
// */ */
// $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships', array_merge([ $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships', array_merge([
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders())); ], $this->getHeaders()));
// $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertIsInt($response['body']['sum']); $this->assertIsInt($response['body']['sum']);
// $this->assertNotEmpty($response['body']['memberships'][0]['$id']); $this->assertNotEmpty($response['body']['memberships'][0]['$id']);
// $this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['name']); $this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['name']);
// $this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['email']); $this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['email']);
// $this->assertEquals('owner', $response['body']['memberships'][0]['roles'][0]); $this->assertEquals('owner', $response['body']['memberships'][0]['roles'][0]);
// /** /**
// * Test for FAILURE * Test for FAILURE
// */ */
// return $data; return $data;
// } }
// /** /**
// * @depends testCreateTeam * @depends testCreateTeam
// */ */
// public function testCreateTeamMembership($data):array public function testCreateTeamMembership($data):array
// { {
// $teamUid = $data['teamUid'] ?? ''; $teamUid = $data['teamUid'] ?? '';
// $teamName = $data['teamName'] ?? ''; $teamName = $data['teamName'] ?? '';
// $email = uniqid().'friend@localhost.test'; $email = uniqid().'friend@localhost.test';
// /** /**
// * Test for SUCCESS * Test for SUCCESS
// */ */
// $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([ $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [ ], $this->getHeaders()), [
// 'email' => $email, 'email' => $email,
// 'name' => 'Friend User', 'name' => 'Friend User',
// 'roles' => ['admin', 'editor'], 'roles' => ['admin', 'editor'],
// 'url' => 'http://localhost:5000/join-us#title' 'url' => 'http://localhost:5000/join-us#title'
// ]); ]);
// $this->assertEquals(201, $response['headers']['status-code']); $this->assertEquals(201, $response['headers']['status-code']);
// $this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
// $this->assertNotEmpty($response['body']['userId']); $this->assertNotEmpty($response['body']['userId']);
// $this->assertNotEmpty($response['body']['teamId']); $this->assertNotEmpty($response['body']['teamId']);
// $this->assertCount(2, $response['body']['roles']); $this->assertCount(2, $response['body']['roles']);
// $this->assertIsInt($response['body']['joined']); $this->assertIsInt($response['body']['joined']);
// $this->assertEquals(false, $response['body']['confirm']); $this->assertEquals(false, $response['body']['confirm']);
// $lastEmail = $this->getLastEmail(); $lastEmail = $this->getLastEmail();
// $this->assertEquals($email, $lastEmail['to'][0]['address']); $this->assertEquals($email, $lastEmail['to'][0]['address']);
// $this->assertEquals('Friend User', $lastEmail['to'][0]['name']); $this->assertEquals('Friend User', $lastEmail['to'][0]['name']);
// $this->assertEquals('Invitation to '.$teamName.' Team at '.$this->getProject()['name'], $lastEmail['subject']); $this->assertEquals('Invitation to '.$teamName.' Team at '.$this->getProject()['name'], $lastEmail['subject']);
// $secret = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256); $secret = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
// $membershipUid = substr($lastEmail['text'], strpos($lastEmail['text'], '?membershipId=', 0) + 14, 13); $membershipUid = substr($lastEmail['text'], strpos($lastEmail['text'], '?membershipId=', 0) + 14, 13);
// $userUid = substr($lastEmail['text'], strpos($lastEmail['text'], '&userId=', 0) + 8, 13); $userUid = substr($lastEmail['text'], strpos($lastEmail['text'], '&userId=', 0) + 8, 13);
// /** /**
// * Test for FAILURE * Test for FAILURE
// */ */
// $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([ $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [ ], $this->getHeaders()), [
// 'email' => 'dasdkaskdjaskdjasjkd', 'email' => 'dasdkaskdjaskdjasjkd',
// 'name' => 'Friend User', 'name' => 'Friend User',
// 'roles' => ['admin', 'editor'], 'roles' => ['admin', 'editor'],
// 'url' => 'http://localhost:5000/join-us#title' 'url' => 'http://localhost:5000/join-us#title'
// ]); ]);
// $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals(400, $response['headers']['status-code']);
// $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([ $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [ ], $this->getHeaders()), [
// 'email' => $email, 'email' => $email,
// 'name' => 'Friend User', 'name' => 'Friend User',
// 'roles' => 'bad string', 'roles' => 'bad string',
// 'url' => 'http://localhost:5000/join-us#title' 'url' => 'http://localhost:5000/join-us#title'
// ]); ]);
// $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals(400, $response['headers']['status-code']);
// $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([ $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [ ], $this->getHeaders()), [
// 'email' => $email, 'email' => $email,
// 'name' => 'Friend User', 'name' => 'Friend User',
// 'roles' => ['admin', 'editor'], 'roles' => ['admin', 'editor'],
// 'url' => 'http://example.com/join-us#title' // bad url 'url' => 'http://example.com/join-us#title' // bad url
// ]); ]);
// $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals(400, $response['headers']['status-code']);
// return [ return [
// 'teamUid' => $teamUid, 'teamUid' => $teamUid,
// 'secret' => $secret, 'secret' => $secret,
// 'membershipUid' => $membershipUid, 'membershipUid' => $membershipUid,
// 'userUid' => $userUid, 'userUid' => $userUid,
// ]; ];
// } }
// /** /**
// * @depends testCreateTeamMembership * @depends testCreateTeamMembership
// */ */
// public function testUpdateTeamMembership($data):array public function testUpdateTeamMembership($data):array
// { {
// $teamUid = $data['teamUid'] ?? ''; $teamUid = $data['teamUid'] ?? '';
// $secret = $data['secret'] ?? ''; $secret = $data['secret'] ?? '';
// $membershipUid = $data['membershipUid'] ?? ''; $membershipUid = $data['membershipUid'] ?? '';
// $userUid = $data['userUid'] ?? ''; $userUid = $data['userUid'] ?? '';
// /** /**
// * Test for SUCCESS * Test for SUCCESS
// */ */
// $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([ $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ]), [ ]), [
// 'secret' => $secret, 'secret' => $secret,
// 'userId' => $userUid, 'userId' => $userUid,
// ]); ]);
// $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertNotEmpty($response['body']['$id']); $this->assertNotEmpty($response['body']['$id']);
// $this->assertNotEmpty($response['body']['userId']); $this->assertNotEmpty($response['body']['userId']);
// $this->assertNotEmpty($response['body']['teamId']); $this->assertNotEmpty($response['body']['teamId']);
// $this->assertCount(2, $response['body']['roles']); $this->assertCount(2, $response['body']['roles']);
// $this->assertIsInt($response['body']['joined']); $this->assertIsInt($response['body']['joined']);
// $this->assertEquals(true, $response['body']['confirm']); $this->assertEquals(true, $response['body']['confirm']);
// /** /**
// * Test for FAILURE * Test for FAILURE
// */ */
// $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([ $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ]), [ ]), [
// 'secret' => 'sdasdasd', 'secret' => 'sdasdasd',
// 'userId' => $userUid, 'userId' => $userUid,
// ]); ]);
// $this->assertEquals(401, $response['headers']['status-code']); $this->assertEquals(401, $response['headers']['status-code']);
// $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([ $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ]), [ ]), [
// 'secret' => '', 'secret' => '',
// 'userId' => $userUid, 'userId' => $userUid,
// ]); ]);
// $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals(400, $response['headers']['status-code']);
// $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([ $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ]), [ ]), [
// 'secret' => $secret, 'secret' => $secret,
// 'userId' => 'sdasd', 'userId' => 'sdasd',
// ]); ]);
// $this->assertEquals(401, $response['headers']['status-code']); $this->assertEquals(401, $response['headers']['status-code']);
// $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([ $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ]), [ ]), [
// 'secret' => $secret, 'secret' => $secret,
// 'userId' => '', 'userId' => '',
// ]); ]);
// $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals(400, $response['headers']['status-code']);
// return $data; return $data;
// } }
// /** /**
// * @depends testUpdateTeamMembership * @depends testUpdateTeamMembership
// */ */
// public function testDeleteTeamMembership($data):array public function testDeleteTeamMembership($data):array
// { {
// $teamUid = $data['teamUid'] ?? ''; $teamUid = $data['teamUid'] ?? '';
// $membershipUid = $data['membershipUid'] ?? ''; $membershipUid = $data['membershipUid'] ?? '';
// /** /**
// * Test for SUCCESS * Test for SUCCESS
// */ */
// $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/'.$membershipUid, array_merge([ $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/'.$membershipUid, array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders())); ], $this->getHeaders()));
// $this->assertEquals(204, $response['headers']['status-code']); $this->assertEquals(204, $response['headers']['status-code']);
// $this->assertEmpty($response['body']); $this->assertEmpty($response['body']);
// /** /**
// * Test for FAILURE * Test for FAILURE
// */ */
// $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships/'.$membershipUid, array_merge([ $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships/'.$membershipUid, array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders())); ], $this->getHeaders()));
// $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertCount(1, $response['body']['memberships']); $this->assertCount(1, $response['body']['memberships']);
// return []; return [];
// } }
/** /**