[TASK] Update copyright year to 2013
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Resource / Repository / AbstractRepositoryTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Resource\Repository;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Andreas Wolf <andreas.wolf@ikt-werk.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Testcase for the abstract repository base class
32 *
33 * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
34 */
35 class AbstractRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
36
37 /**
38 * @var \TYPO3\CMS\Core\Resource\AbstractRepository
39 */
40 private $fixture;
41
42 private $mockedDb;
43
44 private $Typo3DbBackup;
45
46 protected function createDatabaseMock() {
47 $this->mockedDb = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
48 $this->Typo3DbBackup = $GLOBALS['TYPO3_DB'];
49 $GLOBALS['TYPO3_DB'] = $this->mockedDb;
50 }
51
52 public function setUp() {
53 $this->fixture = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\AbstractRepository', array(), '', FALSE);
54 }
55
56 public function tearDown() {
57 if ($this->mockedDb) {
58 $GLOBALS['TYPO3_DB'] = $this->Typo3DbBackup;
59 }
60 }
61
62 /**
63 * @test
64 */
65 public function findByUidFailsIfUidIsString() {
66 $this->setExpectedException('InvalidArgumentException', '', 1316779798);
67 $this->fixture->findByUid('asdf');
68 }
69
70 /**
71 * @test
72 */
73 public function findByUidAcceptsNumericUidInString() {
74 $this->createDatabaseMock();
75 $this->mockedDb->expects($this->once())->method('exec_SELECTgetSingleRow')->with($this->anything(), $this->anything(), $this->stringContains('uid=' . 123))->will($this->returnValue(array('uid' => 123)));
76 $this->fixture->findByUid('123');
77 }
78
79 }
80
81 ?>