Skip to content
Snippets Groups Projects
Select Git revision
  • cf961f344e929ff56d8f98154b6de2601355bf16
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

StructuralElement.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    StudipFileloaderTest.php 1.60 KiB
    <?php
    
    /**
     * Testcase for StudipFileloader class.
     *
     *
     * @author    mlunzena
     * @copyright (c) Authors
     */
    
    class StudipFileloaderTestCase extends \Codeception\Test\Unit
    {
        public function setUp(): void
        {
            ArrayFileStream::set_filesystem([
                'pathto' => [
                    'config-1.php' => '<?php $CONF = 17; ',
                    'config-2.php' => '<?php $CONF = 17 + $offset; ',
                ]
            ]);
    
            if (!stream_wrapper_register('var', 'ArrayFileStream')) {
                new Exception('Failed to register protocol');
            }
        }
    
        public function tearDown(): void
        {
            stream_wrapper_unregister('var');
        }
    
    
        public function test_should_inject_vars()
        {
            $container = [];
            StudipFileloader::load('var://pathto/config-1.php', $container);
            $this->assertEquals(['CONF' => 17], $container);
        }
    
        public function test_should_inject_vars_twice()
        {
            foreach (range(1,2) as $i) {
                $container = [];
                StudipFileloader::load('var://pathto/config-1.php', $container);
            }
            $this->assertEquals(['CONF' => 17], $container);
        }
    
        public function test_should_use_optional_bindings()
        {
            $container = [];
            $offset = 25;
            StudipFileloader::load('var://pathto/config-2.php', $container, compact('offset'));
            $this->assertEquals(['CONF' => 42], $container);
        }
    
        public function test_should_balk_upon_file_not_found()
        {
            $this->expectException(\PHPUnit\Framework\Exception::class);
            StudipFileloader::load('var://pathto/not-there.php', $container);
        }
    }