# |
Oct 14th 2019, 21:17 |
tippexs91 |
Hi @dereuromark. Perfect. Sounds great. So create a new Entity with `$this->Invoices->newEntity([])` and try `$this-Invoices->save($entity)` |
# |
Oct 14th 2019, 21:12 |
dereuromark |
Yeah, you can test e.g. save() directly in Table tests |
# |
Oct 14th 2019, 21:04 |
slackebot1 |
$entity = $invoices->newEntity(['invoicenr' => 'TestInvoice01', 'payment_id' => 1]); $this->assertEmpty($entity->getErrors()); } ``` How to test the isUnique Validation? For me, it feels lightly wrong to test it in the controller? Is it possible to test the validations in the TableTests? Thanks for your help |
# |
Oct 14th 2019, 21:04 |
tippexs91 |
hi @here. Any Testing-Specialist arround? I need to test the Validation-Rules. ``` // InvoicesTable public function buildRules(RulesChecker $rules) { $rules->add($rules->existsIn(['payment_id'], 'Payments')); $rules->add($rules->isUnique(['payment_id'])); return $rules; ``` The Controller-Test ``` public function testAdd() { $invoices = TableRegistry::getTableLocator()->get('Invoices'); |
# |
Oct 14th 2019, 19:08 |
daniel.upshaw |
It's a `select` element on the page |
# |
Oct 14th 2019, 19:01 |
daniel.upshaw |
If I add `$this->Form->unlockField('new_field_name');`, it works, but I can't see why it wouldn't treat it like every other field in the table/model |
# |
Oct 14th 2019, 18:59 |
daniel.upshaw |
This particular application uses `"cakephp/cakephp": "3.5.*"`, so hopefully that's not why |
# |
Oct 14th 2019, 18:58 |
daniel.upshaw |
This is empty, but if I remove the input field that supplies the post data for that column, the form still saves |
# |
Oct 14th 2019, 18:57 |
daniel.upshaw |
`<input type="hidden" name="_Token[unlocked]" autocomplete="off" value="">` |
# |
Oct 14th 2019, 18:57 |
daniel.upshaw |
`Unexpected field in POST data` after adding a new column :S It's added to the `Entity` as accessible, as well as the validator in the `Table`.. The form is created the standard way of `$this->Form->create($modelName);` |
# |
Oct 14th 2019, 18:34 |
ndm |
The plugin installer updates that file when the composer autoloader is dumped. https://github.com/cakephp/app/blob/master/composer.json#L40 It handles both types of plugins, local ones, and ones that are composer dependencies. Bake will trigger the `dump-autoload` command when a plugin is baked. |
# |
Oct 14th 2019, 18:27 |
dereuromark |
Then you need to declare it in root composer.json. see my sandbox for examples. |
# |
Oct 14th 2019, 18:25 |
david |
mmm, but my plugin is not loaded via composer |
# |
Oct 14th 2019, 18:24 |
dereuromark |
composer plugin itself |
# |
Oct 14th 2019, 18:23 |
david |
which command has updated my vendor/cakephp-plugins.php ? |
# |
Oct 14th 2019, 18:20 |
graziel |
no problem its just probably something silly you will find in time |
# |
Oct 14th 2019, 18:20 |
ricksaccous |
now you're baking with cake |
# |
Oct 14th 2019, 18:20 |
david |
thank you! |
# |
Oct 14th 2019, 18:20 |
david |
I will try that way |
# |
Oct 14th 2019, 18:19 |
graziel |
thats why bake is so fun |
# |
Oct 14th 2019, 18:18 |
david |
... |
# |
Oct 14th 2019, 18:18 |
david |
if I bake a plugin and then a plugin shell, it works |
# |
Oct 14th 2019, 18:17 |
david |
hmmmm |
# |
Oct 14th 2019, 18:15 |
graziel |
try to use new installation to bake your plugin |
# |
Oct 14th 2019, 18:13 |
dereuromark |
after commit/backup etc |
# |
Oct 14th 2019, 18:13 |
dereuromark |
also documented is the -o or sth for overwritig existing files |
# |
Oct 14th 2019, 18:13 |
david |
after manually copying bin from a new cakephp installation |
# |
Oct 14th 2019, 18:13 |
david |
no changes |
# |
Oct 14th 2019, 18:10 |
dereuromark |
I actually do, it is documented as "skeleton task" |
# |
Oct 14th 2019, 18:10 |
david |
thank you, I'll try |
# |
Oct 14th 2019, 18:09 |
ricksaccous |
that's one way of doing it lol |
# |
Oct 14th 2019, 18:09 |
graziel |
if yes then check if there are any changes in skeleton app |
# |
Oct 14th 2019, 18:09 |
ricksaccous |
yeah |
# |
Oct 14th 2019, 18:09 |
graziel |
yup if something breaks i just create new app and check if it works there |
# |
Oct 14th 2019, 18:09 |
david |
clone new cakephp app and copy bin to my app, for example? |
# |
Oct 14th 2019, 18:09 |
ricksaccous |
i have to manually do it (kind of) @dereuromark probably has some plugin for that or something, lol |
# |
Oct 14th 2019, 18:08 |
david |
updates? |
# |
Oct 14th 2019, 18:08 |
david |
oh, I see. How do you manage that updated? |
# |
Oct 14th 2019, 18:08 |
ricksaccous |
and if you haven't updated those chances are you forgot to update other essential things |
# |
Oct 14th 2019, 18:07 |
ricksaccous |
the bin/files |
# |
Oct 14th 2019, 18:07 |
ricksaccous |
i mean |