TYPO3 CMS  TYPO3_8-7
DriverRegistryTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 class DriverRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
25  protected $subject;
26 
27  protected function setUp()
28  {
29  $this->initializeSubject();
30  }
31 
32  protected function initializeSubject()
33  {
34  $this->subject = new \TYPO3\CMS\Core\Resource\Driver\DriverRegistry();
35  }
36 
41  {
42  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
43  $this->subject->registerDriverClass($className, 'foobar');
44  $returnedClassName = $this->subject->getDriverClass('foobar');
45  $this->assertEquals($className, $returnedClassName);
46  }
47 
52  {
53  $this->expectException(\InvalidArgumentException::class);
54  $this->expectExceptionCode(1314979197);
55  $this->subject->registerDriverClass($this->getUniqueId());
56  }
57 
62  {
63  $this->expectException(\InvalidArgumentException::class);
64  $this->expectExceptionCode(1314979451);
65  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
66  $className2 = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\DriverInterface::class));
67  $this->subject->registerDriverClass($className, 'foobar');
68  $this->subject->registerDriverClass($className2, 'foobar');
69  }
70 
75  {
76  $this->expectException(\InvalidArgumentException::class);
77  $this->expectExceptionCode(1314085990);
78  $this->subject->getDriverClass($this->getUniqueId());
79  }
80 
85  {
86  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
87  $this->subject->registerDriverClass($className, 'foobar');
88  $this->assertEquals($className, $this->subject->getDriverClass($className));
89  }
90 
95  {
96  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
97  $shortName = $this->getUniqueId();
98  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = [
99  $shortName => [
100  'class' => $className
101  ]
102  ];
103  $this->initializeSubject();
104  $this->assertEquals($className, $this->subject->getDriverClass($shortName));
105  }
106 
111  {
112  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
113  $shortName = $this->getUniqueId();
114  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = [
115  $shortName => [
116  'class' => $className
117  ]
118  ];
119  $this->initializeSubject();
120  $this->assertTrue($this->subject->driverExists($shortName));
121  $this->assertFalse($this->subject->driverExists($this->getUniqueId()));
122  }
123 
128  {
129  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = [
130  ];
131  $this->initializeSubject();
132  $this->assertFalse($this->subject->driverExists($this->getUniqueId()));
133  }
134 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']