Skip to content

Commit

Permalink
Add missing tests for quoteName
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Narloch committed Feb 3, 2017
1 parent 6f85b59 commit 2b4d954
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 0 deletions.
Expand Up @@ -31,6 +31,22 @@ public function dataTestEscape()
);
}

/**
* Data for the testQuoteName test.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function dataTestQuoteName()
{
return array(
array('protected`title', null, '`protected``title`'),
array('protected"title', null, '`protected"title`'),
array('protected]title', null, '`protected]title`'),
);
}

/**
* Data for the testTransactionRollback test.
*
Expand Down Expand Up @@ -126,6 +142,27 @@ public function testEscape($text, $extra, $expected)
$this->assertSame($expected, self::$driver->escape($text, $extra), 'The string was not escaped properly');
}

/**
* Test the quoteName method.
*
* @param string $text The column name or alias to be quote.
* @param string $asPart String used for AS query part.
* @param string $expected The expected result.
*
* @return void
*
* @dataProvider dataTestQuoteName
* @since __DEPLOY_VERSION__
*/
public function testQuoteName($text, $asPart, $expected)
{
$this->assertThat(
self::$driver->quoteName($text, $asPart),
$this->equalTo($expected),
'The name was not quoted properly'
);
}

/**
* Test getAffectedRows method.
*
Expand Down
Expand Up @@ -31,6 +31,22 @@ public function dataTestEscape()
);
}

/**
* Data for the testQuoteName test.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function dataTestQuoteName()
{
return array(
array('protected`title', null, '`protected``title`'),
array('protected"title', null, '`protected"title`'),
array('protected]title', null, '`protected]title`'),
);
}

/**
* Data for the testTransactionRollback test.
*
Expand Down Expand Up @@ -126,6 +142,27 @@ public function testEscape($text, $extra, $expected)
$this->assertThat(self::$driver->escape($text, $extra), $this->equalTo($expected), 'The string was not escaped properly');
}

/**
* Test the quoteName method.
*
* @param string $text The column name or alias to be quote.
* @param string $asPart String used for AS query part.
* @param string $expected The expected result.
*
* @return void
*
* @dataProvider dataTestQuoteName
* @since __DEPLOY_VERSION__
*/
public function testQuoteName($text, $asPart, $expected)
{
$this->assertThat(
self::$driver->quoteName($text, $asPart),
$this->equalTo($expected),
'The name was not quoted properly'
);
}

/**
* Test getAffectedRows method.
*
Expand Down
Expand Up @@ -31,6 +31,22 @@ public function dataTestEscape()
);
}

/**
* Data for the testQuoteName test.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function dataTestQuoteName()
{
return array(
array('protected`title', null, '`protected``title`'),
array('protected"title', null, '`protected"title`'),
array('protected]title', null, '`protected]title`'),
);
}

/**
* Data for the testTransactionRollback test.
*
Expand Down Expand Up @@ -115,6 +131,27 @@ public function testEscape($text, $extra, $expected)
);
}

/**
* Test the quoteName method.
*
* @param string $text The column name or alias to be quote.
* @param string $asPart String used for AS query part.
* @param string $expected The expected result.
*
* @return void
*
* @dataProvider dataTestQuoteName
* @since __DEPLOY_VERSION__
*/
public function testQuoteName($text, $asPart, $expected)
{
$this->assertThat(
self::$driver->quoteName($text, $asPart),
$this->equalTo($expected),
'The name was not quoted properly'
);
}

/**
* Test getAffectedRows method.
*
Expand Down
Expand Up @@ -111,6 +111,10 @@ public function dataTestReplacePrefix()
public function dataTestQuoteName()
{
return array(
/* test escape double quote */
array('protected`title', null, '"protected`title"'),
array('protected"title', null, '"protected""title"'),
array('protected]title', null, '"protected]title"'),
/* no dot inside var */
array('jos_dbtest', null, '"jos_dbtest"'),
/* a dot inside var */
Expand Down
Expand Up @@ -30,6 +30,22 @@ public function dataTestEscape()
);
}

/**
* Data for the testQuoteName test.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function dataTestQuoteName()
{
return array(
array('protected`title', null, '[protected`title]'),
array('protected"title', null, '[protected"title]'),
array('protected]title', null, '[protected]]title]'),
);
}

/**
* Tests the dropTable method.
*
Expand Down Expand Up @@ -67,6 +83,27 @@ public function testEscape($text, $extra, $expected)
);
}

/**
* Test the quoteName method.
*
* @param string $text The column name or alias to be quote.
* @param string $asPart String used for AS query part.
* @param string $expected The expected result.
*
* @return void
*
* @dataProvider dataTestQuoteName
* @since __DEPLOY_VERSION__
*/
public function testQuoteName($text, $asPart, $expected)
{
$this->assertThat(
self::$driver->quoteName($text, $asPart),
$this->equalTo($expected),
'The name was not quoted properly'
);
}

/**
* Tests the getAffectedRows method
*
Expand Down

0 comments on commit 2b4d954

Please sign in to comment.