2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
19 use TYPO3\CMS\Backend\Form\Exception\DatabaseRecordException;
22 use TYPO3\CMS\Core\Tests\UnitTestCase;
41 $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
42 $GLOBALS[
'TYPO3_DB'] = $this->dbProphecy->reveal();
53 'tableName' =>
'tt_content',
61 $this->dbProphecy->quoteStr($input[
'tableName'], $input[
'tableName'])->willReturn($input[
'tableName']);
62 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=' . $input[
'vanillaUid'])->willReturn($resultRow);
63 $this->dbProphecy->exec_SELECTgetSingleRow(Argument::cetera())->willReturn([]);
65 $result = $this->subject->addData($input);
67 $this->assertSame($resultRow, $result[
'databaseRow']);
76 'tableName' =>
'tt_content',
83 $this->dbProphecy->quoteStr($input[
'tableName'], $input[
'tableName'])->willReturn($input[
'tableName']);
84 $this->dbProphecy->exec_SELECTgetSingleRow(
'*',
'tt_content',
'uid=' . $input[
'vanillaUid'])->willReturn($resultRow);
86 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1437663061);
88 $this->subject->addData($input);
97 'tableName' =>
'tt_content',
102 $this->setExpectedException(\InvalidArgumentException::class, $this->anything(), 1437656456);
104 $this->subject->addData($input);
113 'tableName' =>
'tt_content',
118 $this->setExpectedException(\RuntimeException::class, $this->anything(), 1437655862);
120 $this->subject->addData($input);
129 'tableName' =>
'tt_content',
133 $this->dbProphecy->quoteStr(Argument::cetera())->willReturn($input[
'tableName']);
134 $this->dbProphecy->exec_SELECTgetSingleRow(Argument::cetera())->willReturn(
false);
136 $this->setExpectedException(DatabaseRecordException::class, $this->anything(), 1437656081);
138 $this->subject->addData($input);
147 'tableName' =>
'tt_content',
151 $this->dbProphecy->quoteStr(Argument::cetera())->willReturn($input[
'tableName']);
152 $this->dbProphecy->exec_SELECTgetSingleRow(Argument::cetera())->willReturn(
'invalid result data');
154 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1437656323);
156 $this->subject->addData($input);