Skip to content

Commit

Permalink
platform: added IPlatform::getName()
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Jan 10, 2016
1 parent 91fe03f commit fe3f3f8
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Platforms/CachedPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function __construct(Connection $connection, IStorage $storage)
}


public function getName()
{
return $this->platform->getName();
}


public function getTables()
{
return $this->cache->load('tables', function () {
Expand Down
7 changes: 7 additions & 0 deletions src/Platforms/IPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

interface IPlatform
{
/**
* Returns platform name.
* @return string
*/
public function getName();


/**
* Returns list of tables names indexed by table name.
* @return array
Expand Down
6 changes: 6 additions & 0 deletions src/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public function __construct(Connection $connection)
}


public function getName()
{
return 'mysql';
}


public function getTables()
{
$tables = [];
Expand Down
6 changes: 6 additions & 0 deletions src/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public function __construct(Connection $connection)
}


public function getName()
{
return 'postgresql';

This comment has been minimized.

Copy link
@pryznar

pryznar Jan 10, 2016

spaces :)

This comment has been minimized.

Copy link
@hrach

hrach Jan 11, 2016

Author Member

bloody phpstorm!

}


public function getTables()
{
$result = $this->connection->query("
Expand Down
6 changes: 6 additions & 0 deletions tests/cases/integration/platform.mysql.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ class PlatformMysqlTest extends IntegrationTestCase
{
Assert::null($this->connection->getPlatform()->getPrimarySequenceName('books'));
}


public function testName()
{
Assert::same('mysql', $this->connection->getPlatform()->getName());
}
}


Expand Down
6 changes: 6 additions & 0 deletions tests/cases/integration/platform.pgsql.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ class PlatformPostgreTest extends IntegrationTestCase
{
Assert::same('books_id_seq', $this->connection->getPlatform()->getPrimarySequenceName('books'));
}


public function testName()
{
Assert::same('postgresql', $this->connection->getPlatform()->getName());
}
}


Expand Down
7 changes: 7 additions & 0 deletions tests/cases/unit/CachedPlatformTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ class CachedPlatformTest extends TestCase
$cols = $this->platform->getPrimarySequenceName('foo');
Assert::same($expectedPs, $cols);
}


public function testName()
{
$this->platformMock->shouldReceive('getName')->once()->andReturn('foo');
Assert::same('foo', $this->platform->getName());
}
}


Expand Down

0 comments on commit fe3f3f8

Please sign in to comment.