Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Rescue Master Branch PR: TestCase classes should be abstract to prevent warnings #10461

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli mentioned this pull request Aug 23, 2022
5 tasks
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this change, there's no abstract methods in SapphireTest so making this an abstract class just to prevent warnings (of which there are none??) seems like an anti-pattern

We should probably close this unless there's a good reason to keep it

@GuySartorelli
Copy link
Member Author

GuySartorelli commented Aug 24, 2022

prevent warnings (of which there are none??)

There are none because of the hacky workaround which is being removed in this same change:

// We cannot run the tests on this abstract class.
if (static::class == __CLASS__) {
    $this->markTestSkipped(sprintf('Skipping %s ', static::class));
}

abstract doesn't only mean "There are methods here which we want you to implement in your own class" - it can also be used as a way to identify classes which simply should never be instantiated - they're meant to be subclassed, not used directly. That's exactly the use case here.

@emteknetnz
Copy link
Member

There are none because of the hacky workaround which is being removed in this same change

Ah OK, that makes more sense

used as a way to identify classes which simply should never be instantiated - they're meant to be subclassed, not used directly

Sounds good

@emteknetnz emteknetnz merged commit feb57db into silverstripe:5 Aug 24, 2022
@emteknetnz emteknetnz deleted the pulls/5/rescue-master-abstract-testcase branch August 24, 2022 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants