<commit_before><?php

namespace AppBundle\Controller;

use AppBundle\Service\Mailer\MailSenderMock;

class FeedbackControllerTest extends AbstractTestController
{
    private static $tokenAdmin = null;
    private static $tokenDeputy = null;
    
    public function setUp()
    {
        if (null === self::$tokenAdmin) {
            self::$tokenAdmin = $this->loginAsAdmin();
            self::$tokenDeputy = $this->loginAsDeputy();
        }
    }
    
    public function testsendFeedback()
    {
        $url = '/feedback';
        MailSenderMock::resetessagesSent();
        
        $this->assertJsonRequest('POST', $url, [
            'mustSucceed'=>true,
            'AuthToken' => self::$tokenDeputy,
            'data'=>[
                
            ]
        ])['data'];
        
        $this->assertCount(1, MailSenderMock::getMessagesSent()['mailer.transport.smtp.default']);
        $this->assertEquals('User Feedback', MailSenderMock::getMessagesSent()['mailer.transport.smtp.default'][0]['subject']);
    }
}<commit_msg>dd1210 fix feedack test + improve test with client secret check + email contains at least one data var<commit_after><?php

namespace AppBundle\Controller;

use AppBundle\Service\Mailer\MailSenderMock;

class FeedbackControllerTest extends AbstractTestController
{
    private static $tokenAdmin = null;
    private static $tokenDeputy = null;
    
    public function setUp()
    {
        if (null === self::$tokenAdmin) {
            self::$tokenAdmin = $this->loginAsAdmin();
            self::$tokenDeputy = $this->loginAsDeputy();
        }
    }
    
    public function testsendFeedbackMissingClientSecre()
    {
        $url = '/feedback';
        
        $this->assertJsonRequest('POST', $url, [
            'mustFail' => true,
            'assertResponseCode' => 403
        ]);
    }
    
    public function testsendFeedback()
    {
        $url = '/feedback';
        MailSenderMock::resetessagesSent();
        
        $this->assertJsonRequest('POST', $url, [
            'mustSucceed'=>true,
            'ClientSecret' => '123abc-deputy',
            'data'=>[
                'difficulty' => 'difficulty-response'
            ]
        ])['data'];
        
        $this->assertCount(1, MailSenderMock::getMessagesSent()['mailer.transport.smtp.default']);
        $email = MailSenderMock::getMessagesSent()['mailer.transport.smtp.default'][0];
        $this->assertEquals('User Feedback', $email['subject']);
        $this->assertContains('difficulty-response', $email['parts'][0]['body']);
    }
}
{'fraction_non_alphanumeric': 0.1416829745596869, 'fraction_numerical': 0.005870841487279843, 'mean_word_length': 2.520661157024793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1456132', 'n_tokens_mistral': 724, 'n_tokens_neox': 712, 'n_words': 123}