MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/public_html/raquel/vendor/league/plates/test/unit/render-template.spec.php
<?php

use League\Plates\{
    RenderTemplate\FileSystemRenderTemplate,
    RenderTemplate\ComposeRenderTemplate,
    RenderTemplate\MockRenderTemplate,
    Template,
    Exception\RenderTemplateException
};

use function League\Plates\{
    Template\matchStub
};

describe('RenderTemplate', function() {
    describe('MockRenderTemplate', function() {
        it('calls a mock render function based off of the template name', function() {
            $rt = new MockRenderTemplate([
                'a' => function($t) {
                    return 'a-contents';
                }
            ]);
            expect($rt->renderTemplate(new Template('a')))->equal('a-contents');
        });
        it('throws an exception if a mock render does not exist', function() {
            expect(function() {
                $rt = new MockRenderTemplate([]);
                $rt->renderTemplate(new Template('a'));
            })->throw(RenderTemplateException::class);
        });
    });
    describe('FileSystemRenderTemplate', function() {
        it('it delegates rendering to the matched renderer according to the render set', function() {
            $rt = new FileSystemRenderTemplate([
                [matchStub(false), new MockRenderTemplate(['a' => function() { return 'a'; }])],
                [matchStub(true), new MockRenderTemplate(['a' => function() { return 'b'; }])],
            ]);

            expect($rt->renderTemplate(new Template('a')))->equal('b');
        });
        it('throws an exception if no renderer is available', function() {
            expect(function() {
                $rt = new FileSystemRenderTemplate([]);
                $rt->renderTemplate(new Template('a'));
            })->throw(RenderTemplateException::class);
        });
    });
});