Skip to content

Commit

Permalink
test(model): restricted relations with params
Browse files Browse the repository at this point in the history
  • Loading branch information
zsilbi committed Oct 16, 2020
1 parent 1fa339d commit 6bd45ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-4.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ This component can be used to create SQL statements using a fluent interface. Op
- Fixed `Phalcon\Events\Manager:notifyEvent()` change in the order of notification event: first default event manager, then custom events and finally behaviors, [#14904](https://github.com/phalcon/cphalcon/issues/14904)
- Fixed `Phalcon\Validation\Validator\Uniqueness` fixed except query [#15084](https://github.com/phalcon/cphalcon/issues/15084)
- Fixed `Phalcon\Mvc\Model` to also check the params option in cascade relations when deleting [#15098](https://github.com/phalcon/cphalcon/issues/15098)
- Fixed `Phalcon\Mvc\Model` to also check the params option in restricted relations when deleting [#15171](https://github.com/phalcon/cphalcon/issues/15171)
- Fixed `Phalcon\Mvc\Model::findFirst()` to return correct value [#15077](https://github.com/phalcon/cphalcon/issues/15077)
- Fixed `Phalcon\Mvc\Model\CriteriaInterface::where()` parameters [#15144](https://github.com/phalcon/cphalcon/issues/15144)
- Fixed `Phalcon\Http\Response\Cookies::set()` to utilize the options parameter correctly [#15129](https://github.com/phalcon/cphalcon/issues/15129)
Expand Down
21 changes: 21 additions & 0 deletions tests/_data/fixtures/models/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ public function initialize()
}
]
);

$this->hasMany(
'cst_id',
Invoices::class,
'inv_cst_id',
[
'alias' => 'inactiveInvoices',
'reusable' => true,
'foreignKey' => [
'action' => Model\Relation::ACTION_RESTRICT
],
'params' => function () {
return [
'inv_status_flag = :inactive:',
'bind' => [
'inactive' => Invoices::STATUS_INACTIVE
]
];
}
]
);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/database/Mvc/Model/DeleteCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function mvcModelDeleteCascadeRelated(DatabaseTester $I)
$lastName = uniqid('cust-', true);

$customersMigration = new CustomersMigration($connection);
$customersMigration->clear();
$customersMigration->insert($custId, 0, $firstName, $lastName);

$paidInvoiceId = 4;
Expand All @@ -110,6 +111,7 @@ public function mvcModelDeleteCascadeRelated(DatabaseTester $I)
$title = uniqid('inv-');

$invoicesMigration = new InvoicesMigration($connection);
$invoicesMigration->clear();
$invoicesMigration->insert(
$paidInvoiceId,
$custId,
Expand Down

0 comments on commit 6bd45ef

Please sign in to comment.