<commit_before><?php

namespace Ojs\AdminBundle\Tests\Controller;

use Ojs\CoreBundle\Tests\BaseTestSetup as BaseTestCase;

class AdminIndexControllerTest extends BaseTestCase
{
    public function testIndex()
    {
        $this->logIn();
        $client = $this->client;
        $client->request('GET', '/admin/index/');

        $this->assertStatusCode(200, $client);
    }

    public function testNew()
    {
        $this->logIn();
        $client = $this->client;
        $client->request('GET', '/admin/index/new');

        $this->assertStatusCode(200, $client);
    }

    public function testShow()
    {
        $this->logIn();
        $client = $this->client;
        $client->request('GET', '/admin/index/1/show');

        $this->assertStatusCode(200, $client);
    }

    public function testEdit()
    {
        $this->logIn();
        $client = $this->client;
        $client->request('GET', '/admin/index/1/edit');

        $this->assertStatusCode(200, $client);
    }
}<commit_msg>updated tests adminindexcontroller<commit_after><?php

namespace Ojs\AdminBundle\Tests\Controller;

use Ojs\CoreBundle\Tests\BaseTestSetup as BaseTestCase;
use Ojs\JournalBundle\Entity\Index;

class AdminIndexControllerTest extends BaseTestCase
{
    public function testIndex()
    {
        $this->logIn();
        $client = $this->client;
        $client->request('GET', '/admin/index/');

        $this->assertStatusCode(200, $client);
    }

    public function testNew()
    {
        $this->logIn();
        $client = $this->client;
        $crawler = $client->request('GET', '/admin/index/new');

        $this->assertStatusCode(200, $client);

        $form = $crawler->filter('form[name=index]')->form();
        $form['index[name]'] = 'Index Name';
        $form['index[logo]'] = 'f6e2/885d/192d/5771348a32d76.png';
        $form['index[status]']->tick();
        $client->submit($form);
        
        $this->assertTrue($client->getResponse()->isRedirect());
        $client->followRedirect();

        $this->assertContains(
            'Index Name',
            $this->client->getResponse()->getContent()
        );
    }

    public function testShow()
    {
        $this->logIn();
        $client = $this->client;
        $client->request('GET', '/admin/index/1/show');

        $this->assertStatusCode(200, $client);
    }

    public function testEdit()
    {
        $this->logIn();
        $client = $this->client;
        $crawler = $client->request('GET', '/admin/index/2/edit');

        $this->assertStatusCode(200, $client);

        $form = $crawler->filter('form[name=index]')->form();
        $form['index[name]'] = 'Index Name Edit';
        $form['index[status]']->tick();
        $client->submit($form);

        $this->assertTrue($client->getResponse()->isRedirect());
        $client->followRedirect();

        $this->assertContains(
            'Index Name Edit',
            $this->client->getResponse()->getContent()
        );
    }

    public function testDelete()
    {
        $em = $this->em;

        $index = new Index();
        $index->setName('Delete Index - phpunit');
        $index->setLogo('logo.png');
        $index->setStatus(true);

        $em->persist($index);
        $em->flush();

        $id = $index->getId();

        $this->logIn();
        $client = $this->client;
        $token = $this->generateToken('ojs_admin_index'.$id);
        $client->request('DELETE', '/admin/index/'.$id.'/delete', array('_token' => $token));

        $this->assertStatusCode(302, $client);
    }
}

{'fraction_non_alphanumeric': 0.18522695235410205, 'fraction_numerical': 0.014096419509444602, 'mean_word_length': 2.4513618677042803, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 72, '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': '6987383', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1070, 'n_words': 166}