aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests/SPTableCopyTest.m
diff options
context:
space:
mode:
Diffstat (limited to 'UnitTests/SPTableCopyTest.m')
-rw-r--r--UnitTests/SPTableCopyTest.m24
1 files changed, 11 insertions, 13 deletions
diff --git a/UnitTests/SPTableCopyTest.m b/UnitTests/SPTableCopyTest.m
index 0d146827..6a14fa8f 100644
--- a/UnitTests/SPTableCopyTest.m
+++ b/UnitTests/SPTableCopyTest.m
@@ -31,24 +31,19 @@
@implementation SPTableCopyTest
-- (id)getMockConnection
+- (id)mockConnection
{
return [[OCMockObject niceMockForClass:[SPMySQLConnection class]] autorelease];
}
-- (id)getMockResult
+- (id)mockResult
{
- return [OCMockObject niceMockForClass:[SPMySQLResult class]];
-}
-
-- (SPTableCopy *)getTableCopyFixture
-{
- return [[[SPTableCopy alloc] init] autorelease];
+ return [[OCMockObject niceMockForClass:[SPMySQLResult class]] autorelease];
}
- (void)testCopyTableFromToWithData
{
- id mockResult = [self getMockResult];
+ id mockResult = [self mockResult];
unsigned long long varOne = 1;
NSValue *valueOne = [NSValue value:&varOne withObjCType:@encode(__typeof__(varOne))];
@@ -57,22 +52,25 @@
NSValue *valueNo = [NSValue value:&varNo withObjCType:@encode(BOOL)];
NSArray *resultArray = [[NSArray alloc] initWithObjects:@"", @"CREATE TABLE `table_name` ()", nil];
- [[[mockResult expect] andReturnValue:valueOne] numberOfRows];
- [[[mockResult expect] andReturn:resultArray] getRowAsArray];
+ id mockConnection = [self mockConnection];
- id mockConnection = [self getMockConnection];
+ [(SPMySQLResult *)[[mockResult expect] andReturn:valueOne] numberOfRows];
+ [[[mockResult expect] andReturn:resultArray] getRowAsArray];
[[[mockConnection expect] andReturn:mockResult] queryString:@"SHOW CREATE TABLE `source_db`.`table_name`"];
[[mockConnection expect] queryString:@"CREATE TABLE `target_db`.`table_name` ()"];
[[mockConnection expect] queryString:@"INSERT INTO `target_db`.`table_name` SELECT * FROM `source_db`.`table_name`"];
[[[mockConnection stub] andReturnValue:valueNo] queryErrored];
- id tableCopy = [self getTableCopyFixture];
+ SPTableCopy *tableCopy = [[SPTableCopy alloc] init];
[tableCopy setConnection:mockConnection];
[tableCopy copyTable:@"table_name" from:@"source_db" to:@"target_db" withContent:YES];
+
[mockResult verify];
[mockConnection verify];
+
+ [tableCopy release];
[resultArray release];
}