chore: add tests

This commit is contained in:
Christy Jacob
2023-04-29 13:13:33 +05:30
parent 3451d3d800
commit 3f61db57b9
2 changed files with 33 additions and 2 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
>
<extensions>
<extension class="Appwrite\Tests\TestHook" />
@@ -3,6 +3,7 @@
namespace Tests\E2E\Services\Projects;
use Appwrite\Auth\Auth;
use Appwrite\Extend\Exception;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectConsole;
use Tests\E2E\Scopes\SideClient;
@@ -98,7 +99,37 @@ class ProjectsConsoleClientTest extends Scope
$this->assertEquals(400, $response['headers']['status-code']);
return ['projectId' => $projectId];
return [
'projectId' => $projectId,
'teamId' => $team['body']['$id']
];
}
/**
* @depends testCreateProject
*/
public function testCreateDuplicateProject($data)
{
$teamId = $data['teamId'] ?? '';
$projectId = $data['projectId'] ?? '';
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_POST, '/projects', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => $projectId,
'name' => 'Project Duplicate',
'teamId' => $teamId,
'region' => 'default'
]);
$this->assertEquals(403, $response['headers']['status-code']);
$this->assertEquals(403, $response['body']['code']);
$this->assertEquals(Exception::PROJECT_ALREADY_EXISTS, $response['body']['type']);
$this->assertEquals('Project with the requested ID already exists.', $response['body']['message']);
}
/**