Logs for #cakephp

Page 6 of 36,349, showing 100 records out of 3,634,849 total, starting on record 501, ending on 600

# At Username Text
# Oct 15th, 08:57 dereuromark and it is cleaner in terms of semver than using .* :slightly_smiling_face:
# Oct 15th, 08:57 dereuromark well, still, wrong constraint, `~3.3.0` is the one you needed.
# Oct 15th, 08:57 neothermic I didn't mistake anything, this was using `composer create-project --prefer-dist cakephp/app:3.3`
# Oct 15th, 08:56 dereuromark well, you did the mistake of not setting 3rd digit, then ~ would work fine
# Oct 15th, 08:56 neothermic I had to manually alter the composer.json afterwards to change the `cakephp/cakephp: "~3.3"` line to `cakephp/cakephp: "3.3.*"`
# Oct 15th, 08:55 dereuromark or you use "~5.5.9" etc and see if that works
# Oct 15th, 08:55 dereuromark thats how you properly lock it down: https://github.com/dereuromark/cakephp-sandbox/blob/master/composer.json#L123-L125
# Oct 15th, 08:54 neothermic I suppose it is! hmm
# Oct 15th, 08:53 dereuromark thats all correct?
# Oct 15th, 08:51 neothermic despite the fact that the require line in composer.json has: ``` "require": { "php": ">=5.5.9",```
# Oct 15th, 08:51 neothermic install cakephp/app 3.3, and it installs cakephp 3.8.5 ¬_¬
# Oct 15th, 08:50 neothermic well, that's fun
# Oct 15th, 08:35 dereuromark I never do this anti-pattern for usability for this very same reason.
# Oct 15th, 08:35 dereuromark nope, not properly. Try it out with other messages alongside.
# Oct 15th, 08:11 alexdd55976 morning
# Oct 15th, 07:54 conehead Morning
# Oct 15th, 07:54 spriz I am sure we have "already exists" in our UIs, but we have that only in `buildRules` afaik
# Oct 15th, 07:53 spriz I see :thinking_face: But those errors in the `buildRules` is also shown in the UI - aye?
# Oct 15th, 07:47 neon1024 Morning everyone :wave:
# Oct 15th, 07:47 conehead :P
# Oct 15th, 07:41 ruth.cantoni facade
# Oct 15th, 07:38 dereuromark Pretty sure i once Blogged about this^^
# Oct 15th, 07:37 dereuromark Actually that is how it should be done correctly for usability.
# Oct 15th, 07:37 dereuromark @conehead it might just be the status quo of passing tests :)
# Oct 15th, 07:19 spriz That looks like sorcery usage of `Validator` :O :)
# Oct 15th, 06:22 conehead @tippexs91 I don't get your test case? You expect that the result is empty twice. So actually it never should be saved?
# Oct 14th, 22:00 dereuromark https://github.com/dereuromark/cakephp-sandbox/blob/master/plugins/Sandbox/src/Model/Table/AnimalsTable.php#L49 works perfectly for me
# Oct 14th, 21:58 dereuromark so how did you set up the validation? because usually it works.
# Oct 14th, 21:53 tippexs91 make sense to me, but still the question. How to write a suitable test for isUnique Validations? Would be very cool to have the possibility to test this before releasing the production build.
# Oct 14th, 21:49 challgren This would be a prime example of returning a http 402
# Oct 14th, 21:48 tippexs91 Yeah. In this case we need to deal with a not very stable sub-system sending updates to our payments. Therefore the payment_id need to be unique. If I have a entry for a given payment_id already, i will not save the current one and send a 400.
# Oct 14th, 21:37 dereuromark rules are best for data integrity check, especially if you want to catch db constraints early. but for me isUnique is part of validation and should find its way into meaningful user output.
# Oct 14th, 21:33 tippexs91 okay to be clear... validations are good for sementical checks... but not for checks like that?
# Oct 14th, 21:31 dereuromark i sure dont do that :slightly_smiling_face:
# Oct 14th, 21:31 tippexs91 @dereuromark means i should not use this in my table obj ``` public function buildRules(RulesChecker $rules) { $rules->add($rules->existsIn(['payment_id'], 'Payments')); $rules->add($rules->isUnique(['payment_id'])); return $rules; } ```
# Oct 14th, 21:27 dereuromark it is also always better/cleaner to use validation here, as that would be also properly displayed with other validation issues.
# Oct 14th, 21:27 tippexs91 ` // A single field. $rules->add($rules->isUnique(['email'])); `
# Oct 14th, 21:27 dereuromark yeah you are looking for validation rule validateUnique :slightly_smiling_face:
# Oct 14th, 21:27 daniel.upshaw Your `isUnique` is in there, that's probably right... but would think that goes in validation
# Oct 14th, 21:27 daniel.upshaw Oh hmm
# Oct 14th, 21:26 daniel.upshaw Looks like `buildRules` is for associations?
# Oct 14th, 21:26 daniel.upshaw Hmm
# Oct 14th, 21:26 daniel.upshaw ``` * Default validation rules. * * @param \Cake\Validation\Validator $validator Validator instance. * @return \Cake\Validation\Validator */ public function validationDefault(Validator $validator)```
# Oct 14th, 21:26 daniel.upshaw ``` * Returns a rules checker object that will be used for validating * application integrity. * * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. * @return \Cake\ORM\RulesChecker */ public function buildRules(RulesChecker $rules)```
# Oct 14th, 21:25 tippexs91 Oh... Maybe testValidationDefault? Should I add something here?
# Oct 14th, 21:23 tippexs91 Still passing. https://gist.github.com/tippexs/87f3b127f3022263cc1679325e111c38
# Oct 14th, 21:22 dereuromark assertFalse is cleaner usually if it returns entity or false.
# Oct 14th, 21:20 slackebot1 $this->assertEmpty($this->Invoices->save($entity)); } ```
# Oct 14th, 21:20 tippexs91 ``` public function testIsUniquePaymentId() { $config = TableRegistry::exists('Invoices') ? [] : ['className' => InvoicesTable::class]; $this->Invoices = TableRegistry::get('Invoices', $config); $entity = $this->Invoices->newEntity(['payment_id' => 1]); $this->assertEmpty($this->Invoices->save($entity)); $entity = $this->Invoices->newEntity(['payment_id' => 1]);
# Oct 14th, 21:17 tippexs91 will give it a try
# Oct 14th, 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, 21:12 dereuromark Yeah, you can test e.g. save() directly in Table tests
# Oct 14th, 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, 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, 19:08 daniel.upshaw It's a `select` element on the page
# Oct 14th, 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, 18:59 daniel.upshaw This particular application uses `"cakephp/cakephp": "3.5.*"`, so hopefully that's not why
# Oct 14th, 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, 18:57 daniel.upshaw `<input type="hidden" name="_Token[unlocked]" autocomplete="off" value="">`
# Oct 14th, 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, 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, 18:27 dereuromark Then you need to declare it in root composer.json. see my sandbox for examples.
# Oct 14th, 18:25 david mmm, but my plugin is not loaded via composer
# Oct 14th, 18:24 dereuromark composer plugin itself
# Oct 14th, 18:23 david which command has updated my vendor/cakephp-plugins.php ?
# Oct 14th, 18:20 graziel no problem its just probably something silly you will find in time
# Oct 14th, 18:20 ricksaccous now you're baking with cake
# Oct 14th, 18:20 david thank you!
# Oct 14th, 18:20 david I will try that way
# Oct 14th, 18:19 graziel thats why bake is so fun
# Oct 14th, 18:18 david ...
# Oct 14th, 18:18 david if I bake a plugin and then a plugin shell, it works
# Oct 14th, 18:17 david hmmmm
# Oct 14th, 18:15 graziel try to use new installation to bake your plugin
# Oct 14th, 18:13 dereuromark after commit/backup etc
# Oct 14th, 18:13 dereuromark also documented is the -o or sth for overwritig existing files
# Oct 14th, 18:13 david after manually copying bin from a new cakephp installation
# Oct 14th, 18:13 david no changes
# Oct 14th, 18:10 dereuromark I actually do, it is documented as "skeleton task"
# Oct 14th, 18:10 david thank you, I'll try
# Oct 14th, 18:09 ricksaccous that's one way of doing it lol
# Oct 14th, 18:09 graziel if yes then check if there are any changes in skeleton app
# Oct 14th, 18:09 ricksaccous yeah
# Oct 14th, 18:09 graziel yup if something breaks i just create new app and check if it works there
# Oct 14th, 18:09 david clone new cakephp app and copy bin to my app, for example?
# Oct 14th, 18:09 ricksaccous i have to manually do it (kind of) @dereuromark probably has some plugin for that or something, lol
# Oct 14th, 18:08 david updates?
# Oct 14th, 18:08 david oh, I see. How do you manage that updated?
# Oct 14th, 18:08 ricksaccous and if you haven't updated those chances are you forgot to update other essential things
# Oct 14th, 18:07 ricksaccous the bin/files
# Oct 14th, 18:07 ricksaccous i mean
# Oct 14th, 18:07 graziel it gets updated sometimes and ppl forget/dont know they need to update their files manually
# Oct 14th, 18:07 ricksaccous yeah if you've updated cake but haven't updated the bin/bake files that could be the problem
# Oct 14th, 18:07 graziel by app skeleton he ment https://github.com/cakephp/app
# Oct 14th, 18:06 david does*
# Oct 14th, 18:06 david the shell do all the work
# Oct 14th, 18:05 david only the shell
# Oct 14th, 18:05 david i mean, the plugin has no effective code
# Oct 14th, 18:05 david the shell takes the files, rename them, and copy them to my app
# Oct 14th, 18:05 david the plugin is an app skeleton