Skip to content
Snippets Groups Projects
Select Git revision
  • ba52642f0634f211432e877d9dff0d2dec75d806
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

CoursewareBlockComments.vue

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);
        }
    }