Skip to content

Commit

Permalink
add test for foreign key delete/update options
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr42 committed Aug 21, 2018
1 parent 4cb805e commit fddc691
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Converter/Tests/ConditionalConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Digilist\SnakeDumper\Converter\Tests;

use Digilist\SnakeDumper\Converter\ConditionalConverter;
use Digilist\SnakeDumper\Converter\Service\DataConverter;
use PHPUnit\Framework\TestCase;

class ConditionalConverterTest extends \PHPUnit_Framework_TestCase
class ConditionalConverterTest extends TestCase
{

public function testConditionalIfTrue()
Expand Down
3 changes: 2 additions & 1 deletion src/Converter/Tests/RandomConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

use Digilist\SnakeDumper\Converter\RandomConverter;
use Digilist\SnakeDumper\Exception\InvalidArgumentException;
use PHPUnit\Framework\TestCase;

/**
* @package Digilist\SnakeDumper\Converter\Tests
* @author moellers
*/
class RandomConverterTest extends \PHPUnit_Framework_TestCase
class RandomConverterTest extends TestCase
{

public function testEqualBounds()
Expand Down
2 changes: 1 addition & 1 deletion src/Dumper/Sql/Dumper/StructureDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function dumpConstraints(array $tables) {
foreach ($table->getForeignKeys() as $constraint) {
$options = '';
if ($onUpdate = $constraint->onUpdate()) {
$options .= ' ON UPDATE' . $onUpdate;
$options .= ' ON UPDATE ' . $onUpdate;
}
if ($onDelete = $constraint->onDelete()) {
$options .= ' ON DELETE ' . $onDelete;
Expand Down
7 changes: 3 additions & 4 deletions src/Dumper/Sql/Tests/AbstractSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Digilist\SnakeDumper\Dumper\Sql\Tests;

use Digilist\SnakeDumper\Configuration\DatabaseConfiguration;
use Digilist\SnakeDumper\Dumper\Sql\ConnectionHandler;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use PHPUnit\Framework\TestCase;

abstract class AbstractSqlTest extends \PHPUnit_Framework_TestCase
abstract class AbstractSqlTest extends TestCase
{

const DBNAME = 'snakedumper';
Expand Down Expand Up @@ -75,7 +74,7 @@ protected function createTestSchema($randomTables = false)
customer_id INTEGER,
product VARCHAR(100),
amount REAL,
CONSTRAINT customer_id FOREIGN KEY (customer_id) REFERENCES Customer(id)
CONSTRAINT customer_id FOREIGN KEY (customer_id) REFERENCES Customer(id) ON UPDATE CASCADE ON DELETE SET NULL
)');
$pdo->query('CREATE INDEX billing_product ON Billing (product)');

Expand Down
3 changes: 2 additions & 1 deletion src/Dumper/Sql/Tests/TableFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use Digilist\SnakeDumper\Configuration\Table\TableConfiguration;
use Digilist\SnakeDumper\Dumper\Sql\TableFilter;
use Doctrine\DBAL\Schema\Table;
use PHPUnit\Framework\TestCase;

class TableFilterTest extends \PHPUnit_Framework_TestCase
class TableFilterTest extends TestCase
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Dumper/Sql/Tests/test_dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ CREATE TABLE `RandomTable` (`id` INT AUTO_INCREMENT NOT NULL, `name` VARCHAR(10)
INSERT INTO `Customer` (`id`, `name`) VALUES ('1', 'Foobar'), ('2', 'Foobar'), ('3', 'Foobar');
INSERT INTO `Customer` (`id`, `name`) VALUES ('4', 'Foobar');
INSERT INTO `Billing` (`id`, `customer_id`, `product`, `amount`) VALUES ('1', '1', 'IT', '42'), ('2', '1', NULL, '1337'), ('3', '2', 'Some stuff', '1337');
ALTER TABLE `Billing` ADD CONSTRAINT `customer_id` FOREIGN KEY (`customer_id`) REFERENCES `Customer` (`id`);
ALTER TABLE `Billing` ADD CONSTRAINT `customer_id` FOREIGN KEY (`customer_id`) REFERENCES `Customer` (`id`) ON UPDATE CASCADE ON DELETE SET NULL;

0 comments on commit fddc691

Please sign in to comment.