Repository: appwrite/appwrite
File: tests/e2e/Services/Projects/ProjectsConsoleClientTest.php (PHP)

Code before:
        $this->assertEquals('Mailer', $response['body']['smtpSenderName']);
        $this->assertEquals('maildev', $response['body']['smtpHost']);
        $this->assertEquals(1025, $response['body']['smtpPort']);
        $this->assertEquals('user', $response['body']['smtpUsername']);
        $this->assertEquals('password', $response['body']['smtpPassword']);
        $this->assertEquals('', $response['body']['smtpSecure']);

        /** Test Reading Project */
        $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([
            'content-type' => 'application/json',
            'x-appwrite-project' => $this->getProject()['$id'],
        ], $this->getHeaders()));

        $this->assertEquals(200, $response['headers']['status-code']);
        $this->assertTrue($response['body']['smtpEnabled']);
        $this->assertEquals('mailer@appwrite.io', $response['body']['smtpSenderEmail']);
        $this->assertEquals('Mailer', $response['body']['smtpSenderName']);
        $this->assertEquals('maildev', $response['body']['smtpHost']);
        $this->assertEquals(1025, $response['body']['smtpPort']);
        $this->assertEquals('user', $response['body']['smtpUsername']);
        $this->assertEquals('password', $response['body']['smtpPassword']);
        $this->assertEquals('', $response['body']['smtpSecure']);

        return $data;
    }

    /**
     * @group smtpAndTemplates
     * @depends testCreateProject
     */
    public function testCreateProjectSMTPTests($data): array
    {
        $id = $data['projectId'];
        $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/smtp/tests', array_merge([
            'content-type' => 'application/json',
            'x-appwrite-project' => $this->getProject()['$id'],
        ], $this->getHeaders()), [
            'emails' => ['testuser@appwrite.io', 'testusertwo@appwrite.io'],
            'senderEmail' => 'custommailer@appwrite.io',
            'senderName' => 'Custom Mailer',
            'replyTo' => 'reply@appwrite.io',
            'host' => 'maildev',
            'port' => 1025,
            'username' => '',
            'password' => '',
        ]);

        $this->assertEquals(204, $response['headers']['status-code']);

        $emails = $this->getLastEmail(2);
        $this->assertCount(2, $emails);

Review comment (bug):
Please format the comments like the others so it's consistent:


```suggestion
        /**
         * Test for FAILURE
         */
```

Code after:
        $this->assertTrue($response['body']['smtpEnabled']);
        $this->assertEquals('mailer@appwrite.io', $response['body']['smtpSenderEmail']);
        $this->assertEquals('Mailer', $response['body']['smtpSenderName']);
        $this->assertEquals('maildev', $response['body']['smtpHost']);
        $this->assertEquals(1025, $response['body']['smtpPort']);
        $this->assertEquals('user', $response['body']['smtpUsername']);
        $this->assertEquals('password', $response['body']['smtpPassword']);
        $this->assertEquals('', $response['body']['smtpSecure']);

        /** Test Reading Project */
        $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([
            'content-type' => 'application/json',
            'x-appwrite-project' => $this->getProject()['$id'],
        ], $this->getHeaders()));

        $this->assertEquals(200, $response['headers']['status-code']);
        $this->assertTrue($response['body']['smtpEnabled']);
        $this->assertEquals('mailer@appwrite.io', $response['body']['smtpSenderEmail']);
        $this->assertEquals('Mailer', $response['body']['smtpSenderName']);
        $this->assertEquals('maildev', $response['body']['smtpHost']);
        $this->assertEquals(1025, $response['body']['smtpPort']);
        $this->assertEquals('user', $response['body']['smtpUsername']);
        $this->assertEquals('password', $response['body']['smtpPassword']);
        $this->assertEquals('', $response['body']['smtpSecure']);

        /**  Test for Missing or Invalid Credentials*/
        $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/smtp', array_merge([
            'content-type' => 'application/json',
            'x-appwrite-project' => $this->getProject()['$id'],
        ], $this->getHeaders()), [
            'enabled' => true,
            'senderEmail' => 'fail@appwrite.io',
            'senderName' => 'Failing Mailer',
            'host' => 'maildev',
            'port' => 1025,
            'username' => 'invalid-user',
            'password' => 'bad-password',
        ]);
        
        $this->assertEquals(400, $response['headers']['status-code']);
        $this->assertEquals(Exception::PROJECT_SMTP_CONFIG_INVALID, $response['body']['type']);
        $this->assertStringContainsStringIgnoringCase('SMTP authentication failed.', $response['body']['message']);

        return $data;
    }

    /**
     * @group smtpAndTemplates
     * @depends testCreateProject
     */
    public function testCreateProjectSMTPTests($data): array