Skip to content

Commit

Permalink
first test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjgreen committed Sep 14, 2014
1 parent b086384 commit 727b5f7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
Binary file modified build/db-sync.phar
Binary file not shown.
21 changes: 21 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Unit Test Suite">
<directory>./tests/unit/</directory>
</testsuite>
<testsuite name="Integration Test Suite">
<directory>./tests/integration/</directory>
</testsuite>
</testsuites>
</phpunit>
21 changes: 0 additions & 21 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,3 @@ function implode_identifiers(array $columns)

return implode(',', $columns);
}

/*
*
function implode_identifiers(array $columns, $safe = array('as', '.'))
{
$columns = array_map(function($identifier) use($safe){
$parts = preg_split('#([\.\s])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($parts as $i => $part) {
in_array(strtolower($part), $safe) or $parts[$i] = '`' . str_replace('`', '\\`', $part) . '`';
}
return implode('', $parts);
}, $columns);
return implode(',', $columns);
}
*
*/
1 change: 1 addition & 0 deletions tests/load.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
20 changes: 20 additions & 0 deletions tests/unit/FunctionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
class FunctionsTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider providerIdentifiersTest
*
*/
public function testItCorrectlyImplodesIdentifiers($identifiers, $expected)
{
$this->assertEquals($expected, \DbSync\implode_identifiers($identifiers));
}

public function providerIdentifiersTest()
{
return array(
array(array('db.test', 'another.db', ), '`db`.`test`,`another`.`db`'),
array(array('some`thing.e`lse'),'`some\`thing`.`e\`lse`'),
);
}
}

0 comments on commit 727b5f7

Please sign in to comment.