<commit_before><?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

use App\User;
use App\NewsletterSubscription;

class NewsletterSubscriptionsControllerTest extends TestCase
{
    use DatabaseMigrations;

    public function testStore()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];

        $response = $this->actingAs($user)->call('POST', route('newsletter-subscriptions.store'), $params);

        $this->seeInDatabase('newsletter_subscriptions', $params);
        $this->assertResponseStatus('302');
        $this->assertSessionHas('success');
    }

    public function testStoreUniqueFail()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];
        $newsletter = factory(NewsletterSubscription::class)->create($params);

        $response = $this->actingAs($user)->call('POST', route('newsletter-subscriptions.store'), $params);

        $this->assertSessionHasErrors('email');
        $this->assertResponseStatus('302');
    }

    public function testUnsubscribe()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];
        $newsletter = factory(NewsletterSubscription::class)->create($params);

        $response = $this->actingAs($user)->call('GET', route('newsletter-subscriptions.unsubscribe'), $params);

        $this->assertResponseStatus('200');
        $this->assertSessionHas('success', trans('newsletter.unsubscribed'));
    }

    public function testUnsubscribeFail()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];

        $response = $this->actingAs($user)->call('GET', route('newsletter-subscriptions.unsubscribe'), $params);

        $this->assertRedirectedToRoute('home');
        $this->assertSessionHasErrors('email');
    }
}<commit_msg>Adjusting tests to the new error returns in newsletter unsubscription<commit_after><?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

use App\User;
use App\NewsletterSubscription;

class NewsletterSubscriptionsControllerTest extends TestCase
{
    use DatabaseMigrations;

    public function testStore()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];

        $response = $this->actingAs($user)->call('POST', route('newsletter-subscriptions.store'), $params);

        $this->seeInDatabase('newsletter_subscriptions', $params);
        $this->assertResponseStatus('302');
        $this->assertSessionHas('success');
    }

    public function testStoreUniqueFail()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];
        $newsletter = factory(NewsletterSubscription::class)->create($params);

        $response = $this->actingAs($user)->call('POST', route('newsletter-subscriptions.store'), $params);

        $this->assertSessionHasErrors('email');
        $this->assertResponseStatus('302');
    }

    public function testUnsubscribe()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];
        $newsletter = factory(NewsletterSubscription::class)->create($params);

        $response = $this->actingAs($user)->call('GET', route('newsletter-subscriptions.unsubscribe'), $params);

        $this->assertResponseStatus('200');
        $this->assertSessionHas('success', trans('newsletter.unsubscribed'));
    }

    public function testUnsubscribeFail()
    {
        $user = factory(User::class)->create();
        $params = [ 'email' => '<EMAIL>' ];

        $response = $this->actingAs($user)->call('GET', route('newsletter-subscriptions.unsubscribe'), $params);

        $this->assertRedirectedToRoute('home');
        $this->assertSessionHasErrors();
    }
}
{'fraction_non_alphanumeric': 0.16679113766492407, 'fraction_numerical': 0.004480955937266617, 'mean_word_length': 3.8526570048309177, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 65, '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': '3433766', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1097, 'n_words': 169}