Skip to content

Commit

Permalink
Merge pull request #14878 from les-enovateurs/workflow_postgres
Browse files Browse the repository at this point in the history
Add private schema on PostgreSQL tests and update two tests
  • Loading branch information
Jeckerson committed Feb 26, 2020
2 parents cf1b37a + 9b07ad6 commit 2ce20b7
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 39 deletions.
8 changes: 0 additions & 8 deletions tests/_data/assets/schemas/pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ create table co_invoices
inv_created_at timestamp
);

alter table co_invoices owner to postgres;

create index co_invoices_inv_created_at_index
on co_invoices (inv_created_at);

Expand All @@ -39,8 +37,6 @@ create table co_orders
ord_name varchar(70)
);

alter table public.co_orders owner to postgres;



drop table if exists private.co_orders_x_products;
Expand All @@ -52,8 +48,6 @@ create table private.co_orders_x_products
oxp_quantity int not null
);

alter table private.co_orders_x_products owner to postgres;



drop table if exists co_products;
Expand All @@ -66,8 +60,6 @@ create table co_products
prd_name varchar(70)
);

alter table public.co_products owner to postgres;




Expand Down
6 changes: 1 addition & 5 deletions tests/_data/fixtures/Migrations/InvoicesMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ public function insert(
insert into co_invoices (
inv_id, inv_cst_id, inv_status_flag, inv_title, inv_total, inv_created_at
) values (
{$id}, {$custId}, {$status}, "{$title}", {$total}, "{$now}"
{$id}, {$custId}, {$status}, '{$title}', {$total}, '{$now}'
)
SQL;

return $this->connection->exec($sql);
}

Expand Down Expand Up @@ -135,9 +134,6 @@ protected function getSqlPgsql(): array
);
",
"
alter table co_invoices owner to postgres;
",
"
create index co_invoices_inv_created_at_index
on co_invoices (inv_created_at);
",
Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Migrations/OrdersMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ protected function getSqlPgsql(): array
primary key,
ord_name varchar(70)
);
",
"
alter table public.co_orders owner to postgres;
"
];
}
Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Migrations/OrdersProductsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ protected function getSqlPgsql(): array
oxp_prd_id int not null,
oxp_quantity int not null
);
",
"
alter table private.co_orders_x_products owner to postgres;
"
];
}
Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Migrations/ProductsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ protected function getSqlPgsql(): array
primary key,
prd_name varchar(70)
);
",
"
alter table public.co_products owner to postgres;
"
];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/fixtures/Traits/DiTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function newDbConnection(string $driver): AdapterInterface
break;
case 'pgsql':
$options = getOptionsPostgresql();
$service = 'postgresql';
$driver = 'postgresql';
break;
case 'sqlite':
$options = getOptionsSqlite();
Expand Down
9 changes: 1 addition & 8 deletions tests/_envs/pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,4 @@ modules:
reconnect: true
waitlock: 10
initial_queries:
- 'DROP SCHEMA public CASCADE;'
- 'DROP SCHEMA private CASCADE;'
- 'CREATE SCHEMA public;'
- 'CREATE SCHEMA private;'
- 'REVOKE ALL ON SCHEMA public FROM PUBLIC;'
- 'REVOKE ALL ON SCHEMA public FROM %DATA_POSTGRES_USER%;'
- 'GRANT ALL ON SCHEMA public TO %DATA_POSTGRES_USER%;'
- 'GRANT ALL ON SCHEMA public TO public;'
- 'CREATE SCHEMA IF NOT EXISTS private;'
3 changes: 2 additions & 1 deletion tests/database/Db/Adapter/Pdo/QueryCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public function _before(DatabaseTester $I)
* @author Phalcon Team <team@phalcon.io>
* @since 2020-02-22
*
* @group pgsql
* @group mysql
* @group sqlite
*/
public function dbAdapterPdoQuery(DatabaseTester $I)
{
$I->wantToTest('Db\Adapter\Pdo\Mysql - query()');
$I->wantToTest('Db\Adapter\Pdo - query()');

$connection = $I->getConnection();
$db = $this->container->get('db');
Expand Down
15 changes: 8 additions & 7 deletions tests/database/Mvc/Model/Criteria/JoinCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Phalcon\Test\Models\Invoices;
use Phalcon\Test\Models\Orders;
use Phalcon\Test\Models\Products;
use Phalcon\Mvc\Model\Resultset\Simple;

/**
* Class JoinCest
Expand Down Expand Up @@ -74,6 +75,7 @@ public function mvcModelCriteriaJoin(DatabaseTester $I)
* @since 2020-02-06
*
* @group mysql
* @group pgsql
*/
public function mvcModelCriteriaJoinManyToManyMultipleSchema(DatabaseTester $I)
{
Expand All @@ -92,13 +94,12 @@ public function mvcModelCriteriaJoinManyToManyMultipleSchema(DatabaseTester $I)
$builder->from(Orders::class);
$builder->join(Products::class);

$expected = 'SELECT `co_orders`.`ord_id`, `co_orders`.`ord_name` '
. 'FROM `co_orders` '
. 'INNER JOIN `private`.`co_orders_x_products` '
. 'ON `co_orders`.`ord_id` = `co_orders_x_products`.`oxp_ord_id` '
. 'INNER JOIN `co_products` ON `co_orders_x_products`.`oxp_prd_id` = `co_products`.`prd_id`';
$actual = $builder->getQuery()->getSql();
$expected = 'private';
$query = $builder->getQuery();
$request = $query->getSql();

$I->assertEquals($expected, $actual['sql']);
$I->assertContains($expected, $request['sql']);

$I->assertInstanceOf(Simple::class, $query->execute());
}
}

0 comments on commit 2ce20b7

Please sign in to comment.