本文整理汇总了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::expects方法的具体用法?PHP DatabaseConnection::expects怎么用?PHP DatabaseConnection::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Database\DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::expects方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: truncate_multiple_tables_when_configured
/**
* @test
*/
public function truncate_multiple_tables_when_configured()
{
$configuration = ['truncate' => ['test', 'test2', 'test3']];
$processor = $this->getMockBuilder(Configuration::class)->disableOriginalConstructor()->getMock();
$this->connection->expects($this->exactly(3))->method('exec_TRUNCATEquery')->withConsecutive(['test'], ['test2'], ['test3']);
$this->fixture->execute($processor, $configuration);
}
示例2: setUp
/**
* Set up
*
* @return void
*/
protected function setUp()
{
$this->database = $this->getMock(DatabaseConnection::class, array('exec_SELECTgetSingleRow'));
$this->database->expects($this->any())->method('exec_SELECTgetSingleRow')->will($this->returnValue(array('uid' => 0, 'parent' => '')));
$this->treeData = new TreeNode();
$GLOBALS['TYPO3_DB'] = $this->database;
}
示例3: databaseResultIsUsedWhenNoCachedResultIsPresent
/**
* @test
*/
public function databaseResultIsUsedWhenNoCachedResultIsPresent()
{
$fakeConfiguration = array('select.' => array('checkRootPageId' => true, 'checkLanguage' => true, 'SELECT' => '', 'FROM' => '', 'ADD_WHERE' => '', 'GROUP_BY' => '', 'ORDER_BY' => ''), 'limit');
$this->configurationMock->expects($this->once())->method('getSearchFrequentSearchesConfiguration')->will($this->returnValue($fakeConfiguration));
$this->databaseMock->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array(array('search_term' => 'my search', 'hits' => 22))));
//we fake that we have no frequent searches in the cache and therefore expect that the database will be queried
$this->fakeIdentifierNotInCache();
$frequentTerms = $this->frequentSearchesService->getFrequentSearchTerms();
$this->assertSame($frequentTerms, array('my search' => 22), 'Could not retrieve frequent search terms');
}
示例4: parametersAreReplacedInQueryWhenBoundWithBindValues
/**
* Checking if parameters bound to the statement by bindValues()
* are properly replaced in the query.
*
* @test
* @dataProvider parametersAndQueriesDataProvider
* @param string $query Query with unreplaced markers
* @param array $parameters Array of parameters to be replaced in the query
* @param string $expectedResult Query with all markers replaced
* @return void
*/
public function parametersAreReplacedInQueryWhenBoundWithBindValues($query, $parameters, $expectedResult)
{
$statement = $this->createPreparedStatement($query);
$this->databaseStub->expects($this->any())->method('prepare_PREPAREDquery')->with($this->equalTo($expectedResult));
$statement->bindValues($parameters);
$statement->execute();
}
示例5: deleteMethodCallsExpectedDatabaseMethodWithRecord
/**
* @test
*/
public function deleteMethodCallsExpectedDatabaseMethodWithRecord()
{
$table = 'test';
$uid = 123;
$record = array('uid' => 123);
$mock = $this->getMockServiceInstance(array(), array('exec_DELETEquery'));
self::$connectionMock->expects($this->once())->method('exec_DELETEquery')->with($table, "uid = '" . $uid . "'");
$mock->delete($table, $record);
}
示例6: updateQueryCreateValidQuery
/**
* @test
*
* @return void
*/
public function updateQueryCreateValidQuery()
{
$this->subject = $this->getAccessibleMock(DatabaseConnection::class, ['fullQuoteStr'], [], '', false);
$this->subject->expects($this->any())->method('fullQuoteStr')->will($this->returnCallback(function ($data) {
return '\'' . (string) $data . '\'';
}));
$fieldsValues = [$this->testField => 'aTestValue'];
$queryExpected = "UPDATE {$this->testTable} SET {$this->testField}='aTestValue' WHERE id=1";
$queryGenerated = $this->subject->UPDATEquery($this->testTable, 'id=1', $fieldsValues);
$this->assertSame($queryExpected, $queryGenerated);
}
示例7: doesFindByTypeAndTableNameReturnObjects
/**
* @test
*/
public function doesFindByTypeAndTableNameReturnObjects()
{
$testUid = rand(1, 1000);
$testTable = uniqid('sys_collection_');
$type = \TYPO3\CMS\Core\Collection\RecordCollectionRepository::TYPE_Static;
$this->databaseMock->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnCallback(array($this, 'getRowsCallback')));
$this->getRowsCallbackReturnValue = array(array('uid' => $testUid, 'type' => $type, 'table_name' => $this->testTableName), array('uid' => $testUid, 'type' => $type, 'table_name' => $this->testTableName));
$objects = $this->fixture->findByTypeAndTableName($type, $testTable);
$this->assertEquals(2, count($objects));
$this->assertInstanceOf('TYPO3\\CMS\\Core\\Collection\\StaticRecordCollection', $objects[0]);
$this->assertInstanceOf('TYPO3\\CMS\\Core\\Collection\\StaticRecordCollection', $objects[1]);
}
示例8: inputValueCheckDoesNotCallGetDateTimeFormatsForNonDatetimeFields
/**
* @test
* @param array $tcaFieldConf
* @dataProvider inputValueCheckDoesNotCallGetDateTimeFormatsForNonDatetimeFieldsDataProvider
*/
public function inputValueCheckDoesNotCallGetDateTimeFormatsForNonDatetimeFields($tcaFieldConf)
{
$this->mockDatabaseConnection->expects($this->never())->method('getDateTimeFormats');
$this->subject->checkValue_input(array(), '', $tcaFieldConf, array());
}
示例9: assertDatabaseWillNeverBeQueried
/**
* @return void
*/
protected function assertDatabaseWillNeverBeQueried()
{
$this->databaseMock->expects($this->never())->method('exec_SELECTgetRows');
}