diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index b8aa1063a..38d985ab0 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -405,7 +405,6 @@ trait AccountBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertIsArray($response['body']); $this->assertNotEmpty($response['body']); - $this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']['$id']); $this->assertIsNumeric($response['body']['registration']); $this->assertEquals($response['body']['email'], $email); @@ -473,7 +472,6 @@ trait AccountBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertIsArray($response['body']); $this->assertNotEmpty($response['body']); - $this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']['$id']); $this->assertIsNumeric($response['body']['registration']); $this->assertEquals($response['body']['email'], $email); @@ -540,7 +538,6 @@ trait AccountBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertIsArray($response['body']); $this->assertNotEmpty($response['body']); - $this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']['$id']); $this->assertIsNumeric($response['body']['registration']); $this->assertEquals($response['body']['email'], $newEmail); @@ -598,7 +595,6 @@ trait AccountBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertIsArray($response['body']); $this->assertNotEmpty($response['body']); - $this->assertNotEmpty($response['body']); $this->assertEquals('prefValue1', $response['body']['prefs']['prefKey1']); $this->assertEquals('prefValue2', $response['body']['prefs']['prefKey2']); diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 2a0eea743..498037d3e 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -260,10 +260,10 @@ class AccountCustomClientTest extends Scope /** * @depends testCreateAnonymousAccount */ - public function testUpdateAccountPassword($session):array + public function testUpdateAnonymousAccountPassword($session):array { /** - * Test for SUCCESS + * Test for FAILURE */ $response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([ 'origin' => 'http://localhost', @@ -272,7 +272,7 @@ class AccountCustomClientTest extends Scope 'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session, ]), [ 'password' => 'new-password', - 'oldPassword' => null, + 'oldPassword' => '', ]); $this->assertEquals($response['headers']['status-code'], 400); @@ -280,6 +280,31 @@ class AccountCustomClientTest extends Scope return []; } + /** + * @depends testUpdateAnonymousAccountPassword + */ + public function testUpdateAnonymousAccountEmail($session):array + { + $email = uniqid().'new@localhost.test'; + + /** + * Test for FAILURE + */ + $response = $this->client->call(Client::METHOD_PATCH, '/account/email', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session, + ]), [ + 'email' => $email, + 'password' => '', + ]); + + $this->assertEquals($response['headers']['status-code'], 401); + + return []; + } + /** * @depends testCreateAnonymousAccount */ @@ -304,32 +329,10 @@ class AccountCustomClientTest extends Scope $this->assertEquals($response['headers']['status-code'], 200); $this->assertIsArray($response['body']); $this->assertNotEmpty($response['body']); - $this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']['$id']); $this->assertIsNumeric($response['body']['registration']); $this->assertEquals($response['body']['email'], $email); - /** - * Test for FAILURE - */ - $response = $this->client->call(Client::METHOD_PATCH, '/account/email', array_merge([ - 'origin' => 'http://localhost', - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ])); - - $this->assertEquals($response['headers']['status-code'], 401); - - $response = $this->client->call(Client::METHOD_PATCH, '/account/email', array_merge([ - 'origin' => 'http://localhost', - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session, - ]), [ - ]); - - $this->assertEquals($response['headers']['status-code'], 400); - return []; } } \ No newline at end of file