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

Add integration tests for DataExtensions applied #41

Conversation

NightJar
Copy link
Contributor

@NightJar NightJar commented Jun 10, 2018

By this module to classes provided by
bringyourownideas/silverstripe-mainenance

Utilising hook points to alter the report generated by that module, along
with adding relationships to link Package info to Security Alerts. These
now have some rudimentary tests which at least ensure the extensions are
applied automatically iff the requisite module exists.

addresses #35 - but does not close it until this is merged, and then merged up into the master branch (is upgraded to SilverStripe 4 support).

.travis.yml Outdated
- php: 7.0
env: DB=MYSQL CORE_RELEASE=3.6
env: DB=MYSQL CORE_RELEASE=3.6 PHPUNIT_COVERAGE_TEST=1
Copy link
Contributor

Choose a reason for hiding this comment

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

We aren't running coverage in this branch at the moment, this might be a little misleading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it was more a mark in preparation for merging up to master. Can remove if you'd prefer.

{
parent::setUp();
$manifest = new SS_ConfigManifest(BASE_PATH, true);
$moduleDoesNotExist = $manifest->moduleExists('bringyourownideas/silverstripe-maintenance');
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like excessive boilerplate - the standard is to use class_exists. You will also need to run these checks before parent::setUp() otherwise you'll get exceptions from the fixture factory when trying to load non-existent fixture classes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Neat, ta.

{
$package = $this->objFromFixture('Package', 'otheralerts');
$badges = $package->getBadges();
$this->assertEquals(1, $badges->count());
Copy link
Contributor

Choose a reason for hiding this comment

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

$this->assertCount(1, $badges)


public function testGetBadgesHook()
{
$package = $this->objFromFixture('Package', 'otheralerts');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please use Package::class to minimise migration concerns against 2.x-dev?

$this->markTestSkipped(
'Module bringyourownideas/silverstripe-maintenance is required for this test, but is not present.'
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

See comments in previous test class

$this->markTestSkipped(
'Module bringyourownideas/silverstripe-maintenance is required for this test, but is not present.'
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

See comments in previous test class. Is three copies of this comment enough of a reason to make an AbstractMaintenanceTest or something? 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did ponder it - but also thought this very comment (use class_exists instead) might come up, so thought to not spend too much time on it :P
I don't think a simple class_exists call warrants an abstract superclass.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's an example of adding maintenance burden, since you need to update the logic in three places before it's even been merged 😄 if you want to leave it there thats fine too

public function testDisplayColumnsDoesNotIncludePrintingColumns()
{
$report = Injector::inst()->create('SiteSummary');
$this->assertArrayNotHasKey('listSecurityAlertIdentifiers', $report->columns());
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a weak test really, can you also check that it is included in one of the other methods, then check that it's not in the printing columns?

{
// The themes should not affect the test.
// Ensure we use the default template supplied with this module.
Config::inst()->update('SSViewer', 'theme_enabled', false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably worth putting this into the setUp method

$content,
'ensure our extension doesn\'t override all others'
);
// Content is translatable, check for the identifying class instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes but we don't normally check for translated text in any unit tests. If you want to you could add _t() calls into the tests (which is done occasionally) otherwise it's not worth mentioning this. Essentially here you're testing that the class is rendered into the template, and that's fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So ultimately you're saying I should remove this comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess so 😆

@NightJar NightJar force-pushed the pulls/1.0/mild-integration-tests branch 4 times, most recently from 731d3c2 to 91b6d27 Compare June 11, 2018 01:44
By this module to classes provided by
bringyourownideas/silverstripe-mainenance

Utilising hook points to alter the report generated by that module, along
with adding relationships to link Package info to Security Alerts. These
now have some rudimentary tests which at least ensure the extensions are
applied automatically iff the requisite module exists.
@NightJar NightJar force-pushed the pulls/1.0/mild-integration-tests branch from 91b6d27 to a1d6457 Compare June 11, 2018 01:45
@robbieaverill robbieaverill merged commit e59bdec into bringyourownideas:1 Jun 11, 2018
@robbieaverill robbieaverill deleted the pulls/1.0/mild-integration-tests branch June 11, 2018 21:32
@robbieaverill
Copy link
Contributor

I'll merge this up now

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.

2 participants