[BUGFIX] Fix the unit tests to work with PHPUnit 3.6
[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 protected function tearDown() {
53 t3lib_div::purgeInstances();
54 }
55
56 /**********************************
57 * Storage Collections
58 **********************************/
59
60 /**
61 * @test
62 */
63 public function createStorageCollectionObjectCreatesCollectionWithCorrectArguments() {
64 $mockedMount = $this->getMock('t3lib_file_Storage', array(), array(), '', FALSE);
65 $path = uniqid();
66 $name = uniqid();
67
68 $storageCollection = $this->fixture->createFolderObject($mockedMount, $path, $name, 0);
69
70 $this->assertSame($mockedMount, $storageCollection->getStorage());
71 $this->assertEquals($path . '/', $storageCollection->getIdentifier());
72 $this->assertEquals($name, $storageCollection->getName());
73 }
74
75 /**********************************
76 * Drivers
77 **********************************/
78
79 /**
80 * @test
81 */
82 public function getDriverObjectAcceptsDriverClassName() {
83 $mockedDriver = $this->getMock('t3lib_file_Driver_AbstractDriver', array(), array(), '', FALSE);
84 $driverFixtureClass = get_class($mockedDriver);
85 t3lib_div::addInstance($driverFixtureClass, $mockedDriver);
86 $mockedMount = $this->getMock('t3lib_file_Storage', array(), array(), '', FALSE);
87 $mockedRegistry = $this->getMock('t3lib_file_Driver_DriverRegistry');
88 $mockedRegistry->expects($this->once())->method('getDriverClass')->with($this->equalTo($driverFixtureClass))
89 ->will($this->returnValue($driverFixtureClass));
90 t3lib_div::setSingletonInstance('t3lib_file_Driver_DriverRegistry', $mockedRegistry);
91
92 $obj = $this->fixture->getDriverObject($driverFixtureClass, array());
93 $this->assertInstanceOf('t3lib_file_Driver_AbstractDriver', $obj);
94 }
95 }
96 ?>