TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
PreparedStatementTest Class Reference
Inheritance diagram for PreparedStatementTest:
UnitTestCase BaseTestCase

Public Member Functions

 setUpAndReturnDatabaseStubReturnsMockObjectOfDatabaseConnection ()
 
 createPreparedStatementReturnsInstanceOfPreparedStatementClass ()
 
 parametersAndQueriesDataProvider ()
 
 parametersAreReplacedByQuestionMarkInQueryByCallingExecute ($query, $parameters, $expectedResult)
 
 parametersAreReplacedInQueryWhenBoundWithBindValues ($query, $parameters, $expectedResult)
 
 invalidParameterTypesPassedToBindValueThrowsExceptionDataProvider ()
 
 invalidParameterTypesPassedToBindValueThrowsException ($parameter, $type, $exceptionCode)
 
 passingInvalidMarkersThrowsExceptionDataProvider ()
 
 passingInvalidMarkersThrowsException ($query, $parameters)
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from UnitTestCase
 tearDown ()
 
- Protected Member Functions inherited from BaseTestCase
 getAccessibleMock ($originalClassName, $methods=[], array $arguments=[], $mockClassName= '', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)
 
 getAccessibleMockForAbstractClass ($originalClassName, array $arguments=[], $mockClassName= '', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true, $mockedMethods=[])
 
 buildAccessibleProxy ($className)
 
 callInaccessibleMethod ($object, $name,...$arguments)
 
 inject ($target, $name, $dependency)
 
 getUniqueId ($prefix= '')
 

Protected Attributes

 $databaseStub
 
- Protected Attributes inherited from UnitTestCase
 $backupGlobalsBlacklist = ['TYPO3_LOADED_EXT']
 
 $testFilesToDelete = []
 
- Protected Attributes inherited from BaseTestCase
 $backupGlobals = true
 
 $backupStaticAttributes = false
 

Private Member Functions

 setUpAndReturnDatabaseStub ()
 
 createPreparedStatement ($query)
 

Detailed Description

Test case

Definition at line 23 of file Unit/Database/PreparedStatementTest.php.

Member Function Documentation

createPreparedStatementReturnsInstanceOfPreparedStatementClass ( )
invalidParameterTypesPassedToBindValueThrowsException (   $parameter,
  $type,
  $exceptionCode 
)

Checking if an exception is thrown if invalid parameters are provided vor bindValue().

Test:
invalidParameterTypesPassedToBindValueThrowsExceptionDataProvider
Parameters
mixed$parameterParameter to be replaced in the query
int$typeType of the parameter value
int$exceptionCodeExpected exception code
Returns
void

Definition at line 246 of file Unit/Database/PreparedStatementTest.php.

References PreparedStatementTest\createPreparedStatement().

invalidParameterTypesPassedToBindValueThrowsExceptionDataProvider ( )
parametersAndQueriesDataProvider ( )

Data Provider for two tests, providing sample queries, parameters and expected result queries.

See also
parametersAreReplacedInQueryByCallingExecute
parametersAreReplacedInQueryWhenBoundWithBindValues
Returns
array

Definition at line 106 of file Unit/Database/PreparedStatementTest.php.

parametersAreReplacedByQuestionMarkInQueryByCallingExecute (   $query,
  $parameters,
  $expectedResult 
)

Checking if calling execute() with parameters, they are properly replaced in the query.

Test:
parametersAndQueriesDataProvider
Parameters
string$queryQuery with unreplaced markers
array$parametersArray of parameters to be replaced in the query
string$expectedResultQuery with all markers replaced
Returns
void

Definition at line 148 of file Unit/Database/PreparedStatementTest.php.

References PreparedStatementTest\createPreparedStatement().

parametersAreReplacedInQueryWhenBoundWithBindValues (   $query,
  $parameters,
  $expectedResult 
)

Checking if parameters bound to the statement by bindValues() are properly replaced in the query.

Test:
parametersAndQueriesDataProvider
Parameters
string$queryQuery with unreplaced markers
array$parametersArray of parameters to be replaced in the query
string$expectedResultQuery with all markers replaced
Returns
void

Definition at line 168 of file Unit/Database/PreparedStatementTest.php.

References PreparedStatementTest\createPreparedStatement().

passingInvalidMarkersThrowsException (   $query,
  $parameters 
)

Checks if an exception is thrown, if parameter have invalid marker named.

Test:
passingInvalidMarkersThrowsExceptionDataProvider
Parameters
string$queryQuery with unreplaced markers
array$parametersArray of parameters to be replaced in the query
Returns
void

Definition at line 301 of file Unit/Database/PreparedStatementTest.php.

References PreparedStatementTest\createPreparedStatement().

passingInvalidMarkersThrowsExceptionDataProvider ( )

Data Provider for invalid marker names.

See also
passingInvalidMarkersThrowsExeption
Returns
array

text

text

text

text

text

Definition at line 261 of file Unit/Database/PreparedStatementTest.php.

setUp ( )
protected

Create a new database mock object for every test and backup the original global database object.

Returns
void

Definition at line 36 of file Unit/Database/PreparedStatementTest.php.

References PreparedStatementTest\setUpAndReturnDatabaseStub().

setUpAndReturnDatabaseStub ( )
private

Set up the stub to be able to get the result of the prepared statement.

Returns

Definition at line 49 of file Unit/Database/PreparedStatementTest.php.

References $GLOBALS, and BaseTestCase\getAccessibleMock().

Referenced by PreparedStatementTest\setUp(), and PreparedStatementTest\setUpAndReturnDatabaseStubReturnsMockObjectOfDatabaseConnection().

setUpAndReturnDatabaseStubReturnsMockObjectOfDatabaseConnection ( )

Member Data Documentation

$databaseStub
protected

Definition at line 28 of file Unit/Database/PreparedStatementTest.php.