TYPO3 CMS  TYPO3_7-6
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 
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->setExpectedException('InvalidArgumentException', '', 1314979197);
54  $this->subject->registerDriverClass($this->getUniqueId());
55  }
56 
61  {
62  $this->setExpectedException('InvalidArgumentException', '', 1314979451);
63  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
64  $className2 = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\DriverInterface::class));
65  $this->subject->registerDriverClass($className, 'foobar');
66  $this->subject->registerDriverClass($className2, 'foobar');
67  }
68 
73  {
74  $this->setExpectedException('InvalidArgumentException', '', 1314085990);
75  $this->subject->getDriverClass($this->getUniqueId());
76  }
77 
82  {
83  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
84  $this->subject->registerDriverClass($className, 'foobar');
85  $this->assertEquals($className, $this->subject->getDriverClass($className));
86  }
87 
92  {
93  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
94  $shortName = $this->getUniqueId();
95  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = [
96  $shortName => [
97  'class' => $className
98  ]
99  ];
100  $this->initializesubject();
101  $this->assertEquals($className, $this->subject->getDriverClass($shortName));
102  }
103 
108  {
109  $className = get_class($this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class));
110  $shortName = $this->getUniqueId();
111  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = [
112  $shortName => [
113  'class' => $className
114  ]
115  ];
116  $this->initializesubject();
117  $this->assertTrue($this->subject->driverExists($shortName));
118  $this->assertFalse($this->subject->driverExists($this->getUniqueId()));
119  }
120 
125  {
126  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] = [
127  ];
128  $this->initializesubject();
129  $this->assertFalse($this->subject->driverExists($this->getUniqueId()));
130  }
131 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']