PHP Classes

File: tests/FunctionsTest.php

Recommend this page to a friend!
  Packages of Rodolfo Berrios Arce   Workflow   tests/FunctionsTest.php   Download  
File: tests/FunctionsTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Workflow
Create and run action workflows
Author: By
Last change:
Date: 1 year ago
Size: 1,373 bytes
 

 

Contents

Class file image Download
<?php

/*
 * This file is part of Chevere.
 *
 * (c) Rodolfo Berrios <rodolfo@chevere.org>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Chevere\Tests;

use Chevere\Tests\src\TestActionNoParamsArrayIntResponse;
use Chevere\Workflow\Jobs;
use Chevere\Workflow\Workflow;
use PHPUnit\Framework\TestCase;
use function Chevere\Workflow\async;
use function Chevere\Workflow\sync;
use function Chevere\Workflow\workflow;

final class FunctionsTest extends TestCase
{
    public function testFunctionWorkflow(): void
    {
        $workflow = workflow();
        $this->assertEquals(new Workflow(new Jobs()), $workflow);
    }

    public function testFunctionSync(): void
    {
        $action = new TestActionNoParamsArrayIntResponse();
        $job = sync($action);
        $fileLine = __FILE__ . ':' . (__LINE__ - 1);
        $this->assertSame($fileLine, $job->caller()->__toString());
        $this->assertTrue($job->isSync());
    }

    public function testFunctionAsync(): void
    {
        $action = new TestActionNoParamsArrayIntResponse();
        $job = async($action);
        $fileLine = __FILE__ . ':' . (__LINE__ - 1);
        $this->assertSame($fileLine, $job->caller()->__toString());
        $this->assertFalse($job->isSync());
    }
}