TYPO3 CMS  TYPO3_6-2
ImageScriptServiceTest.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 
19 
24 
28  protected $subject;
29 
34 
38  protected function setUp() {
39  $this->subject = new ImageService();
40  $this->environmentService = $this->getMock('TYPO3\\CMS\\Extbase\\Service\\EnvironmentService');
41  $this->inject($this->subject, 'environmentService', $this->environmentService);
42  }
43 
48  $reference = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Resource\\FileReference', array(), array(), '', FALSE);
49  $file = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
50  $file->expects($this->once())->method('process')->willReturn($this->getMock('TYPO3\\CMS\\Core\\Resource\\ProcessedFile', array(), array(), '', FALSE));
51  $reference->expects($this->once())->method('getOriginalFile')->willReturn($file);
52  $reference->_set('file', $file);
53 
54  $this->subject->applyProcessingInstructions($reference, array());
55  }
56 
61  return array(
62  'with scheme' => array('http://foo.bar/img.jpg', 'http://foo.bar/img.jpg'),
63  'scheme relative' => array('//foo.bar/img.jpg', '//foo.bar/img.jpg'),
64  'without scheme' => array('foo.bar/img.jpg', '/prefix/foo.bar/img.jpg'),
65  );
66  }
67 
72  public function prefixIsCorrectlyAppliedToGetImageUri($imageUri, $expected) {
73  $this->environmentService->expects($this->any())->method('isEnvironmentInFrontendMode')->willReturn(TRUE);
74  $GLOBALS['TSFE'] = new \stdClass();
75  $GLOBALS['TSFE']->absRefPrefix = '/prefix/';
76 
77  $file = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
78  $file->expects($this->once())->method('getPublicUrl')->willReturn($imageUri);
79 
80  $this->assertSame($expected, $this->subject->getImageUri($file));
81  }
82 
83 }
inject($target, $name, $dependency)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]