I noticed that Drupal\rest\Plugin\Type\ResourcePluginManager has no mechanism for dealing with #1780396: Namespaces of disabled modules are registered during test runs, which indicated that it didn't have any test plugins.

This means that we don't really have test coverage for what a resource plugin should do.

Comments

klausi’s picture

At the very least a resource plugin MUST implement the routes() and permissions() methods as well as PluginInspectionInterface. I think we should introduce a ResourceInterface for this, currently it is implicit behaviour expected of a plugin.

A resource plugin SHOULD extend ResourceBase and it will get a lot of logic for free.

When using ResourceBase a plugin MAY implement HTTP methods as PHP methods such as get(), post(), put() etc.

Not sure why we should have a test plugin? I can assume that the plugin system works and is tested elsewhere? And when we create ResourceInterface it is clear what a plugin should do?

tim.plunkett’s picture

An implementation of the interface (once #1874820: Resource plugins miss an interface is in) should be explicitly unit tested, not just implicitly tested elsewhere.

tim.plunkett’s picture

Issue summary: View changes
Issue tags: +PHPUnit

We still don't have any tests for this, PHPUnit would be nice here.

clemens.tolboom’s picture

How should we write those tests? I cannot find a PluginTest example yet.

modules/tour/src/Tests/TourPluginTest.php does extend KernelTestBase which is not PHPUnit
modules/rest/src/Tests/Views/StyleSerializerTest.php seemed better but is complete views dependent.

Wim Leers’s picture

Title: Missing test REST plugins » Missing test coverage for \Drupal\rest\Plugin\ResourceInterface plugins
Issue tags: +Novice, +php-novice
Wim Leers’s picture

Category: Bug report » Task
afi13’s picture

Assigned: Unassigned » afi13

I am on it.

zpul’s picture

hi, @afi13: I would like to try this issue... do you have any updates so far?

afi13’s picture

hi, @zpul, it's good idea, because i have no time for now. You can take it.

afi13’s picture

Assigned: afi13 » Unassigned
zpul’s picture

Assigned: Unassigned » zpul

@afi13: thanx, assigned to me

tstoeckler’s picture

Issue tags: +DrupalBCDays

@zpul: Are you still working on this?

Tentatively tagging as #DrupalBCDays to keep it on the radar for someone at the sprint on the weekend...

zpul’s picture

Assigned: zpul » Unassigned

@tstoeckler: hi, need to drop on this issue, too much work pressure currently

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tetranz’s picture

I'm happy to have a go at this but I need some clarification about what we need.

I can see how to build a resource plugin and write some tests for it.

Don't we effectively already have this with the EntityResource plugin? It is part of the rest module and has some tests.

I guess I'm misunderstanding what's missing.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mradcliffe’s picture

Issue tags: -Novice

Cleaning up issue tags.

Wim Leers’s picture

Title: Missing test coverage for \Drupal\rest\Plugin\ResourceInterface plugins » Add unit test coverage for \Drupal\rest\Plugin\Type\ResourcePluginManager, \Drupal\rest\Plugin\ResourceInterface and \Drupal\rest\Plugin\ResourceInterface
Issue tags: -DrupalBCDays
Related issues: +#2737719: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method

#2737719: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method added explicit test coverage for the EntityResource plugin implementation.

Retitling per @tim.plunkett in #2 and before.

tim.plunkett’s picture

Status: Active » Closed (works as designed)

This may have become obsolete after #1874820: Resource plugins miss an interface

When I opened this there was no \Drupal\rest\Plugin\ResourceInterface, so no way to know which methods were available or what they did.

I noticed that there was no coverage of ResourcePluginManager, because there had been a bug that affected all subclasses of DefaultPluginManager, and only RPM didn't fail.

Looking at ResourcePluginManager now, and knowing how much more robust DefaultPluginManager is, and since the only method (ResourcePluginManager::getInstance()) is now deprecated, I think we can close this.