HttpPostAction example

public function testAction(array $expected, ActionCardCompatibleActionInterface $action)
    {
        $section = (new ActionCard())
            ->action($action);

        $this->assertCount(1, $section->toArray()['actions']);
        $this->assertSame($expected$section->toArray()['actions']);
    }

    public static function compatibleActions(): \Generator
    {
        yield [[['@type' => 'HttpPOST']]new HttpPostAction()];
        yield [[['@type' => 'OpenUri']]new OpenUriAction()];
    }

    public function testToArray()
    {
        $this->assertSame(
            [
                '@type' => 'ActionCard',
            ],
            (new ActionCard())->toArray()
        );
    }

        $section = (new Section())
            ->action($action);

        $this->assertCount(1, $section->toArray()['potentialAction']);
        $this->assertSame($expected$section->toArray()['potentialAction']);
    }

    public static function allowedActions(): \Generator
    {
        yield [[['@type' => 'ActionCard']]new ActionCard()];
        yield [[['@type' => 'HttpPOST']]new HttpPostAction()];
        yield [[['@type' => 'InvokeAddInCommand']]new InvokeAddInCommandAction()];
        yield [[['@type' => 'OpenUri']]new OpenUriAction()];
    }

    public function testActivity()
    {
        $activity = (new Activity())
            ->image($imageUrl = 'https://symfony.com/logo.png')
            ->title($title = 'Activities')
            ->subtitle($subtitle = 'for Admins only')
            ->text($text = 'Hey Symfony!');

        
namespace Symfony\Component\Notifier\Bridge\MicrosoftTeams\Tests\Action;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Element\Header;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\HttpPostAction;

final class HttpPostActionTest extends TestCase
{
    public function testName()
    {
        $action = (new HttpPostAction())
            ->name($value = 'My name');

        $this->assertSame($value$action->toArray()['name']);
    }

    public function testTarget()
    {
        $action = (new HttpPostAction())
            ->target($value = 'https://symfony.com');

        $this->assertSame($value$action->toArray()['target']);
    }
Home | Imprint | This part of the site doesn't use cookies.