Skip to content
Snippets Groups Projects
Select Git revision
  • 675791459f9ad72dca78ec0dc691a1951f339c36
  • 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

IndexApp.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.
    ResourceAssignmentTest.php 5.34 KiB
    <?php
    
    
    /**
     * ResourceBookingTest.php - A test for the resource booking functionality.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     *
     * @author      Moritz Strohm <strohm@data-quest.de>
     * @copyright   2017-2020
     * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
     * @category    Stud.IP
     * @package     tests
     * @since       4.5
     */
    
    class ResourceAssignmentTest extends \Codeception\Test\Unit
    {
        protected $db_handle;
        protected $oldPerm, $oldUser;
    
        protected function _before()
        {
            //First we must initialise the StudipPDO database connection:
            $this->db_handle = new \StudipPDO(
                'mysql:host='
                    . $GLOBALS['DB_STUDIP_HOST']
                    . ';dbname='
                    . $GLOBALS['DB_STUDIP_DATABASE'],
                $GLOBALS['DB_STUDIP_USER'],
                $GLOBALS['DB_STUDIP_PASSWORD']
            );
    
            //Then we must start a transaction before we access the database,
            //otherwise we would spam the live database with test data!
            $this->db_handle->beginTransaction();
    
            //Now we tell the DBManager about the connection
            //we have established to the Stud.IP database:
            \DBManager::getInstance()->setConnection('studip', $this->db_handle);
    
            \Config::get()->setValue('LOG_ENABLE', false);
    
            // Workaround old-style Stud.IP-API using $GLOBALS['user']
            $this->oldUser = $GLOBALS['user'];
            $GLOBALS['user'] = new \Seminar_User(
                \User::build(['user_id' => 'cli', 'username' => 'cli', 'perms' => 'root'], false)
            );
            $this->oldPerm = $GLOBALS['perm'];
            $GLOBALS['perm'] = new \Seminar_Perm();
    
            //As a final step we create the SORM objects for our test cases:
    
            $this->test_user_username = 'test_user_' . date('YmdHis');
            $this->test_user = new User();
            $this->test_user->username = $this->test_user_username;
            $this->test_user->vorname = 'Test';
            $this->test_user->nachname = 'User';
            $this->test_user->perms = 'admin';
            $this->test_user->store();
    
            $perm = new ResourcePermission();
            $perm->user_id = $this->test_user->id;
            $perm->resource_id = 'global';
            $perm->perms = 'admin';
            $perm->store();