16f59eeec5efe1bc2365af6e23e1b743e645d5a4
[Packages/TYPO3.CMS.git] / tests / t3lib / file / FactoryTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2011 Andreas Wolf <andreas.wolf@ikt-werk.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 require_once 'vfsStream/vfsStream.php';
27
28 /**
29 * Testcase for the factory of FAL
30 *
31 * @package TYPO3
32 * @subpackage t3lib
33 *
34 * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
35 */
36 class t3lib_file_FactoryTest extends Tx_Phpunit_TestCase {
37
38 /**
39 * @var t3lib_file_Factory
40 */
41 private $fixture;
42
43 /**
44 * @var bool
45 */
46 private $objectCreated = FALSE;
47
48 public function setUp() {
49 $this->fixture = new t3lib_file_Factory();
50 }
51
52 /**********************************
53 * Storage Collections
54 **********************************/
55
56 /**
57 * @test
58 */
59 public function createStorageCollectionObjectCreatesCollectionWithCorrectArguments() {
60 $mockedMount = $this->getMock('t3lib_file_Storage', array(), array(), '', FALSE);
61 $path = uniqid();
62 $name = uniqid();
63
64 $storageCollection = $this->fixture->createFolderObject($mockedMount, $path, $name, 0);
65
66 $this->assertSame($mockedMount, $storageCollection->getStorage());
67 $this->assertEquals($path . '/', $storageCollection->getIdentifier());
68 $this->assertEquals($name, $storageCollection->getName());
69 }
70
71 /**********************************
72 * Drivers
73 **********************************/
74
75 /**
76 * @test
77 */
78 public function getDriverObjectAcceptsDriverClassName() {
79 $mockedDriver = $this->getMock('t3lib_file_Driver_AbstractDriver', array(), array(), '', FALSE);
80 $driverFixtureClass = get_class($mockedDriver);
81 t3lib_div::addInstance($driverFixtureClass, $mockedDriver);
82 $mockedMount = $this->getMock('t3lib_file_Storage', array(), array(), '', FALSE);
83 $mockedRegistry = $this->getMock('t3lib_file_Driver_DriverRegistry');
84 $mockedRegistry->expects($this->once())->method('getDriverClass')->with($this->equalTo($driverFixtureClass))
85 ->will($this->returnValue($driverFixtureClass));
86 t3lib_div::setSingletonInstance('t3lib_file_Driver_DriverRegistry', $mockedRegistry);
87
88 $obj = $this->fixture->getDriverObject($driverFixtureClass, array());
89 $this->assertInstanceOf('t3lib_file_Driver_AbstractDriver', $obj);
90 }
91 }
92 ?>