TYPO3 CMS  TYPO3_6-2
AbstractRepositoryTest.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $subject;
28 
29  protected $mockedDb;
30 
31  protected function createDatabaseMock() {
32  $this->mockedDb = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
33  $GLOBALS['TYPO3_DB'] = $this->mockedDb;
34  }
35 
36  public function setUp() {
37  $this->subject = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\AbstractRepository', array(), '', FALSE);
38  }
39 
43  public function findByUidFailsIfUidIsString() {
44  $this->setExpectedException('InvalidArgumentException', '', 1316779798);
45  $this->subject->findByUid('asdf');
46  }
47 
52  $this->createDatabaseMock();
53  $this->mockedDb->expects($this->once())->method('exec_SELECTgetSingleRow')->with($this->anything(), $this->anything(), $this->stringContains('uid=' . 123))->will($this->returnValue(array('uid' => 123)));
54  $this->subject->findByUid('123');
55  }
56 
63  public function getWhereClauseForEnabledFieldsIncludesDeletedCheckInBackend() {
64  $GLOBALS['TCA'] = array(
65  'sys_file_storage' => array(
66  'ctrl' => array(
67  'delete' => 'deleted',
68  ),
69  ),
70  );
72  $storageRepositoryMock = $this->getAccessibleMock(
73  'TYPO3\\CMS\\Core\\Resource\\StorageRepository',
74  array('dummy'),
75  array(),
76  '',
77  FALSE
78  );
79  $result = $storageRepositoryMock->_call('getWhereClauseForEnabledFields');
80  $this->assertContains('sys_file_storage.deleted=0', $result);
81  }
82 
90  $GLOBALS['TSFE'] = new \stdClass();
91  $sysPageMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
92  $GLOBALS['TSFE']->sys_page = $sysPageMock;
93  $sysPageMock
94  ->expects($this->once())
95  ->method('deleteClause')
96  ->with('sys_file_storage');
97  $storageRepositoryMock = $this->getAccessibleMock(
98  'TYPO3\\CMS\\Core\\Resource\\StorageRepository',
99  array('getEnvironmentMode'),
100  array(),
101  '',
102  FALSE
103  );
104  $storageRepositoryMock->expects($this->any())->method('getEnvironmentMode')->will($this->returnValue('FE'));
105  $storageRepositoryMock->_call('getWhereClauseForEnabledFields');
106  }
107 
108 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]