Log message #4186431

# At Username Text
# May 15th 2019, 13:07 dereuromark I need to manually Router::connect() everywhere
# May 15th 2019, 12:57 dereuromark Still cant find my routes in the component test case
# May 15th 2019, 12:57 dereuromark @spriz Nope, I got those and doesnt work. I even manually loaded routes.php file and did Router::reload() before that one.
# May 15th 2019, 12:52 admad @waspinator show the debug of entity after calling `patchEntity()`
# May 15th 2019, 12:39 waspinator so the relationship for user 2 being a `teacher` in this group is lost
# May 15th 2019, 12:39 waspinator in the example, only the first is saved
# May 15th 2019, 12:38 waspinator if the `id`s of the users are different it works
# May 15th 2019, 12:38 waspinator yes, it has a primary key. it works most of the time, but not for a case where the ids are the same. For example, adding the same user to a user group but with different roles ``` object(ArrayObject) { name => 'test' users => [ (int) 0 => [ 'id' => (int) 2, '_joinData' => [ 'role' => 'student' ] ], (int) 1 => [ 'id' => (int) 2, '_joinData' => [ 'role' => 'teacher' ] ] ] } ```
# May 15th 2019, 12:36 admad does your join table have primary key?
# May 15th 2019, 12:35 admad `through` config is only for association setup, not patchEntity()
# May 15th 2019, 12:34 slackebot $this->belongsToMany('Students', [ 'through' => 'CoursesMemberships', ]); } } class CoursesMembershipsTable extends Table { public function initialize(array $config) { $this->belongsTo('Students'); $this->belongsTo('Courses'); } } ```
# May 15th 2019, 12:34 waspinator @admad so that would be in the `through` table or as the third parameter of `patchEntity()`? I pretty much have this table setup ``` class StudentsTable extends Table { public function initialize(array $config) { $this->belongsToMany('Courses', [ 'through' => 'CoursesMemberships', ]); } } class CoursesTable extends Table { public function initialize(array $config) {
# May 15th 2019, 12:30 admad @waspinator you would configure it in the association config
# May 15th 2019, 12:29 spriz Besides that, last time we had issues with routes and plugins we had missed something when doing https://book.cakephp.org/3.0/en/development/application.html#adding-the-new-http-stack-to-an-existing-application, and moved some things around between `webroot/index.php`, `config/bootstrap.php` and `src/Application` so maybe double check that list @dereuromark:slightly_smiling_face:
# May 15th 2019, 12:29 waspinator it works fine otherwise. just not when two items have the same ids
# May 15th 2019, 12:28 waspinator I have a through model, not sure what I need to configure for this specific case though.
# May 15th 2019, 12:28 admad @waspinator have you configured the `through` model?
# May 15th 2019, 12:24 waspinator how would I make `patchEntity` take `_joinData` into considerations when processing `belongsToMany` data? I want to add two relationships with the same `foreignKey` and `targetForeignKey`, but with different `_joinData`. In `beforeMarshal` I can see both items, but in `beforeSave` only the first one is there.
# May 15th 2019, 12:21 spriz We resolved some issue with no routes in our test, but I see now that we solved it by moving to Routes middleware :S
# May 15th 2019, 12:15 admad I have subscribed to that issue :(
# May 15th 2019, 12:14 spriz and `<phpunit colors="true" bootstrap="./tests/bootstrap.php">` in your `phpunit.xml`?
# May 15th 2019, 12:14 spriz You do have a `require $root . '/config/bootstrap.php';` in your `plugins/PluginName/tests/bootstrap.php` @dereuromark?
# May 15th 2019, 12:13 spriz Done :slightly_smiling_face: https://github.com/rectorphp/rector/issues/1431
# May 15th 2019, 12:08 dereuromark that one contains the RoutingMiddleware, but I am not sure how to invoke this fake Application.php class in TestApp/App namespace
# May 15th 2019, 12:08 admad @spriz i would definitely open an issue in that case
# May 15th 2019, 12:08 dereuromark Application in test_files is also not loaded right now.
# May 15th 2019, 12:07 spriz Ah, so not in terms of how do you make the integration test cases pick up the routes @dereuromark? :P
# May 15th 2019, 12:06 spriz not only in dry-run :)
# May 15th 2019, 12:06 spriz @admad it actually does apply the change: https://gist.github.com/Spriz/93f0a79c9d1c5257713c2a783f1a0f1f
# May 15th 2019, 12:05 dereuromark as entity->toArray() does recursive afaik
# May 15th 2019, 12:05 dereuromark manually foreach ($features as $key => $feature) { $features[$key] = $feature->toArray(); } for all keys works for now
# May 15th 2019, 12:03 spriz @dereuromark using middleware?
# May 15th 2019, 12:02 dereuromark How can one get routes to work in plugin tests? I tried Router::reload(), doesnt seem to load my routes config file either.
# May 15th 2019, 12:02 spriz I'll try and let it do it's thing
# May 15th 2019, 12:02 spriz I only did `--dry-run`
# May 15th 2019, 12:01 admad So is it actually changing calls to static methods or you just assumed it will do so?
# May 15th 2019, 12:00 spriz Yeah I just saw that it should only do that for things thart are not static
# May 15th 2019, 12:00 spriz Yeah it is https://github.com/rectorphp/rector/blob/master/packages/Php/src/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php
# May 15th 2019, 11:59 admad It shouldn't make changes for method which are declared as static
# May 15th 2019, 11:59 admad @spriz this seems to be the rector in question https://github.com/rectorphp/rector/blob/master/docs/AllRectorsOverview.md#staticcallonnonstatictoinstancecallrector But the example shown is fine because the method isn't declared static.
# May 15th 2019, 11:54 admad maybe it has a config to prevent such change?