Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add private schema on PostgreSQL tests and update two tests #14878

Merged
merged 3 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}