Skip to content

Commit

Permalink
Cleanup after merge of mevdschee#244
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed Apr 15, 2017
1 parent 4a517b9 commit 9b28263
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 2,496 deletions.
118 changes: 1 addition & 117 deletions tests/MysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function getCapabilities($db)
public function seedDatabase($db, $capabilities)
{
$fixture = __DIR__.'/data/blog_mysql.sql';

$contents = file_get_contents($fixture);

if (!($capabilities & self::GIS)) {
Expand All @@ -98,121 +99,4 @@ public function seedDatabase($db, $capabilities)
die("Loading '$fixture' failed on statemement #$i with error:\n".mysqli_error($db)."\n");
}
}

/**
* Gets the path to the seed file based on the version of MySQL
*
* @return string
*/
protected static function getSeedFile()
{
if (static::$mysql_version >= self::MYSQL_57) {
return __DIR__.'/data/blog_'.strtolower(static::$config['dbengine']).'_57.sql';
} elseif (static::$mysql_version >= self::MYSQL_56) {
return __DIR__.'/data/blog_'.strtolower(static::$config['dbengine']).'_56.sql';
}
return __DIR__.'/data/blog_'.strtolower(static::$config['dbengine']).'_55.sql';
}

public function testHidingPasswordColumn()
{
parent::testHidingPasswordColumn();
}

public function testMissingIntermediateTable()
{
$test = new API($this, static::$config);
$test->get('/users?include=posts,tags');
$test->expect('{"users":{"columns":["id","username","location"],"records":[[1,"user1",null]]},"posts":{"relations":{"user_id":"users.id"},"columns":["id","user_id","category_id","content"],"records":[[1,1,1,"blog started"],[2,1,2,"It works!"]]},"post_tags":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","tag_id"],"records":[[1,1,1],[2,1,2],[3,2,1],[4,2,2]]},"tags":{"relations":{"id":"post_tags.tag_id"},"columns":["id","name"],"records":[[1,"funny"],[2,"important"]]}}');
}

public function testEditUserPassword()
{
parent::testEditUserPassword();
}

public function testEditUserLocation()
{
parent::testEditUserLocation();
}

public function testListUserLocations()
{
parent::testListUserLocations();
}

public function testEditUserWithId()
{
parent::testEditUserWithId();
}

public function testReadOtherUser()
{
parent::testReadOtherUser();
}

public function testEditOtherUser()
{
parent::testEditOtherUser();
}

public function testSpatialFilterWithin()
{
if (static::$mysql_version < self::MYSQL_56) {
$this->markTestSkipped("MySQL < 5.6 does not support JSON fields.");
}
parent::testSpatialFilterWithin();
}


public function testListProductsProperties()
{
if (static::$mysql_version < self::MYSQL_57) {
$this->markTestSkipped("MySQL < 5.7 does not support JSON fields.");
}
parent::testListProductsProperties();
}

public function testReadProductProperties()
{
if (static::$mysql_version < self::MYSQL_57) {
$this->markTestSkipped("MySQL < 5.7 does not support JSON fields.");
}
parent::testReadProductProperties();
}

public function testWriteProductProperties()
{
if (static::$mysql_version < self::MYSQL_57) {
$this->markTestSkipped("MySQL < 5.7 does not support JSON fields.");
}
parent::testWriteProductProperties();
}

public function testListProducts()
{
parent::testListProducts();
}

public function testAddProducts()
{
if (static::$mysql_version < self::MYSQL_57) {
$this->markTestSkipped("MySQL < 5.7 does not support JSON fields.");
}
parent::testAddProducts();
}

public function testSoftDeleteProducts()
{
if (static::$mysql_version < self::MYSQL_57) {
$test = new API($this, static::$config);
$test->delete('/products/1');
$test->expect('1');
$test->get('/products?columns=id,deleted_at');
$test->expect('{"products":{"columns":["id","deleted_at"],"records":[[1,"2013-12-11 11:10:09"]]}}');
} else {
parent::testSoftDeleteProducts();
}
}

}
102 changes: 1 addition & 101 deletions tests/PostgresqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,108 +95,8 @@ public function seedDatabase($db,$capabilities)
foreach ($queries as $i=>$query) {
if (!pg_query($db, $query.';')) {
$i++;
die("Loading '$seed_file' failed on statemement #$i with error:\n".print_r( pg_last_error($db), true)."\n");
die("Loading '$fixture' failed on statemement #$i with error:\n".print_r( pg_last_error($db), true)."\n");
}
}
}

/**
* Gets the path to the seed file based on the version of Postgres and GIS extension
*
* @return string
*/
protected function getSeedFile()
{
$filepath = __DIR__.'/data/blog_'.strtolower(static::$config['dbengine']);

if (version_compare(static::$pg_server_version, '9.4.0') >= 0 ) {
$filepath .= '_94';
} elseif (version_compare(static::$pg_server_version, '9.2.0') >= 0 ) {
$filepath .= '_92';
} else {
$filepath .= '_91';
}
if (static::$gis_installed) {
$filepath .= '_gis';
}
return $filepath.'.sql';
}

/**
* Determines whether the GIS extension is installed or not based on array of extensions.
*
* @return boolean
*/
protected function isGisInstalled($extensions = [])
{
static::$gis_installed = false;
if ($extensions) {
foreach ($extensions as $extension) {
if ($extension['extname'] === 'postgis') {
static::$gis_installed = true;
break;
}
}
}
return static::$gis_installed;
}

public function testSpatialFilterWithin()
{
if (!static::$gis_installed) {
$this->markTestSkipped("Postgis not installed");
}
parent::testSpatialFilterWithin();
}

public function testListProductsProperties()
{
if (version_compare(static::$pg_server_version, '9.2.0') < 0) {
$this->markTestSkipped("Postgres < 9.2.0 does not support JSON fields.");
}
parent::testListProductsProperties();
}

public function testReadProductProperties()
{
if (version_compare(static::$pg_server_version, '9.2.0') < 0) {
$this->markTestSkipped("Postgres < 9.2.0 does not support JSON fields.");
}
parent::testReadProductProperties();
}

public function testWriteProductProperties()
{
if (version_compare(static::$pg_server_version, '9.2.0') < 0) {
$this->markTestSkipped("Postgres < 9.2.0 does not support JSON fields.");
}
parent::testWriteProductProperties();
}

public function testListProducts()
{
parent::testListProducts();
}

public function testAddProducts()
{
if (version_compare(static::$pg_server_version, '9.2.0') < 0) {
$this->markTestSkipped("Postgres < 9.2.0 does not support JSON fields.");
}
parent::testAddProducts();
}

public function testSoftDeleteProducts()
{
if (version_compare(static::$pg_server_version, '9.2.0') < 0) {
$test = new API($this, static::$config);
$test->delete('/products/1');
$test->expect('1');
$test->get('/products?columns=id,deleted_at');
$test->expect('{"products":{"columns":["id","deleted_at"],"records":[[1,"2013-12-11 11:10:09"]]}}');
} else {
parent::testSoftDeleteProducts();
}
}

}
File renamed without changes.
148 changes: 0 additions & 148 deletions tests/data/blog_mysql_55.sql

This file was deleted.

Loading

0 comments on commit 9b28263

Please sign in to comment.