Skip to content

Commit

Permalink
Don’t need to mock everything to replace setMethodsExcept
Browse files Browse the repository at this point in the history
  • Loading branch information
jastraat committed Apr 5, 2023
1 parent 3a2131b commit 31156c9
Showing 1 changed file with 2 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,7 @@ public function testGetBaseType($frictionless_type, $expected_type) {
// Mock an object so we don't have to set up dependencies.
$mysql_query = $this->getMockBuilder(MySQLQuery::class)
->disableOriginalConstructor()
// Don't mock the method we're testing: getBaseType.
->onlyMethods([
'buildBoolPreAlterCommands',
'sanitizeFields',
'sanitizeIndexes',
'mergeFields',
'mergeIndexes',
'getTableColsAndComments',
'getFieldType',
'buildTypeArgs',
'buildDatePreAlterCommands',
'buildAlterCommand',
'buildDatabaseTypeMap',
'buildModifyColumnOptions',
'buildAddIndexOptions',
'getIndexType',
'buildIndexFieldOption',
'getMaxColumnLength',
'buildPreAlterCommands',
])
->onlyMethods([])
->getMock();

// getBaseType() is protected.
Expand Down Expand Up @@ -208,27 +189,7 @@ public function testBuildPreAlterCommandsForBool() {
$mysql_query = $this->getMockBuilder(MySQLQuery::class)
->disableOriginalConstructor()
// Mock buildBoolPreAlterCommands() so we can set expectations on it.
->onlyMethods([
'buildBoolPreAlterCommands',
'sanitizeFields',
'sanitizeIndexes',
'mergeFields',
'mergeIndexes',
'getTableColsAndComments',
'getFieldType',
'buildTypeArgs',
'buildDatePreAlterCommands',
'buildAlterCommand',
'buildDatabaseTypeMap',
'buildModifyColumnOptions',
'buildAddIndexOptions',
'getIndexType',
'buildIndexFieldOption',
'getMaxColumnLength',
])
// Don't mock these methods because they're called from
// buildPreAlterCommands()
// buildPreAlterCommands, getBaseType
->onlyMethods(['buildBoolPreAlterCommands'])
->getMock();
$mysql_query->expects($this->once())
->method('buildBoolPreAlterCommands')
Expand Down

0 comments on commit 31156c9

Please sign in to comment.