OpenUriAction example

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

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\OpenUriAction;
use Symfony\Component\Notifier\Exception\InvalidArgumentException;

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

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

    public function testTargetWithDefaultValue()
    {
        $action = (new OpenUriAction())
            ->target($uri = 'URI');

        $this->assertSame(
            [

        $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()
        );
    }
}
public function testSectionViaSetter()
    {
        $options = (new MicrosoftTeamsOptions())
            ->section($section = new Section());

        $this->assertSame([$section->toArray()]$options->toArray()['sections']);
    }

    public function testActionViaConstructor()
    {
        $options = new MicrosoftTeamsOptions([
            'potentialAction' => $actions = [(new OpenUriAction())->toArray()],
        ]);

        $this->assertSame($actions$options->toArray()['potentialAction']);
    }

    public function testActionViaSetter()
    {
        $options = (new MicrosoftTeamsOptions())
            ->action($action = new OpenUriAction());

        $this->assertSame([$action->toArray()]$options->toArray()['potentialAction']);
    }
->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!');

        $section = (new Section())
            
Home | Imprint | This part of the site doesn't use cookies.