Spaces:
No application file
No application file
File size: 2,112 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
<?php
declare(strict_types=1);
namespace MauticPlugin\MauticFocusBundle\Tests\Controller\Api;
use Mautic\CoreBundle\Test\MauticMysqlTestCase;
use PHPUnit\Framework\Assert;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
final class FocusApiControllerTest extends MauticMysqlTestCase
{
/**
* @var array<string,mixed>
*/
private array $testPayload = [
'name' => 'test',
'type' => 'notice',
'website' => 'http://',
'style' => 'bar',
'htmlMode' => 1,
'html' => '<div><strong style="color:red">html mode enabled</strong></div>',
'properties' => [
'bar' => [
'allow_hide' => 1,
'sticky' => 1,
'size' => 'large',
'placement' => 'top',
],
'modal' => [
'placement' => 'top',
],
'notification' => [
'placement' => 'top_left',
],
'animate' => 1,
'link_activation' => 1,
'colors' => [
'primary' => '27184e',
],
'content' => [
'headline' => '',
'font' => 'Arial, Helvetica, sans-serif',
],
'when' => 'immediately',
'frequency' => 'everypage',
'stop_after_conversion' => 1,
],
];
public function testFocusApiNew(): void
{
// Create a focus item.
$this->client->request(Request::METHOD_POST, '/api/focus/new', $this->testPayload);
$response = $this->client->getResponse();
$this->assertEquals(Response::HTTP_CREATED, $response->getStatusCode(), $response->getContent());
$createdItem = json_decode($response->getContent(), true)['focus'];
Assert::assertNotEmpty($createdItem['id'], $response->getContent());
Assert::assertSame($this->testPayload['name'], $createdItem['name'], $response->getContent());
}
}
|