mautic / app /bundles /CampaignBundle /Tests /Controller /CampaignControllerTest.php
chrisbryan17's picture
Upload folder using huggingface_hub
d2897cd verified
<?php
namespace Mautic\CampaignBundle\Tests\Controller;
use Mautic\CoreBundle\Test\MauticMysqlTestCase;
use PHPUnit\Framework\Assert;
use Symfony\Component\HttpFoundation\Response;
class CampaignControllerTest extends MauticMysqlTestCase
{
/**
* Index should return status code 200.
*/
public function testIndexActionWhenNotFiltered(): void
{
$this->client->request('GET', '/s/campaigns');
$clientResponse = $this->client->getResponse();
$this->assertSame(200, $clientResponse->getStatusCode(), 'Return code must be 200.');
}
/**
* Filtering should return status code 200.
*/
public function testIndexActionWhenFiltering(): void
{
$this->client->request('GET', '/s/campaigns?search=has%3Aresults&tmpl=list');
$clientResponse = $this->client->getResponse();
$this->assertSame(200, $clientResponse->getStatusCode(), 'Return code must be 200.');
}
/**
* Get campaign's create page.
*/
public function testNewActionCampaign(): void
{
$this->client->request('GET', '/s/campaigns/new/');
$clientResponse = $this->client->getResponse();
$clientResponseContent = $clientResponse->getContent();
$this->assertEquals(Response::HTTP_OK, $clientResponse->getStatusCode());
}
/**
* Test cancelling new campaign does not give a 500 error.
*
* @see https://github.com/mautic/mautic/issues/11181
*/
public function testNewActionCampaignCancel(): void
{
$crawler = $this->client->request('GET', '/s/campaigns/new/');
$clientResponse = $this->client->getResponse();
Assert::assertSame(Response::HTTP_OK, $clientResponse->getStatusCode());
$form = $crawler->filter('form[name="campaign"]')->selectButton('campaign_buttons_cancel')->form();
$this->client->submit($form);
$clientResponse = $this->client->getResponse();
Assert::assertSame(Response::HTTP_OK, $clientResponse->getStatusCode());
}
}