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

Make DB connection name configurable #14 #23

Closed
wants to merge 12 commits into from
Closed

Make DB connection name configurable #14 #23

wants to merge 12 commits into from

Conversation

liviakuenzli
Copy link
Contributor

@liviakuenzli liviakuenzli commented Oct 1, 2019

@ravage84 I tried implementing your suggestion in #14, please take a look 😇

Closes #14

@ravage84 ravage84 added this to the 2.2.x milestone Oct 2, 2019
Copy link
Member

@ravage84 ravage84 left a comment

Choose a reason for hiding this comment

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

Thanks ❤️, @liviascapin

Please have a look at my changes and add some tests indicated by the @todo annotations.

Copy link
Contributor Author

@liviakuenzli liviakuenzli left a comment

Choose a reason for hiding this comment

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

Maybe you could help me figure out how to test this method :) If you want, you can write the test yourself and merge the branch. Or we can wait until I'm back.

* @return string The name of the connection to check.
* @todo Cover by a test.
*/
protected function _getSetting(string $name, $default = null): string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ravage84 I'm not sure how to test this.
Maybe it should be public? Or maybe you have an idea on how to test it.

Copy link
Member

Choose a reason for hiding this comment

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

No, it doesn't need to. Sure it would make testing easier, but code doesn't need to change just for the sake of testability.

This can be tested by a test dummy. A class that extends Sensor and then implements a public method which simply calls _getSettings() and returns it.
This public method can be called in the test case and its return value be assserted. The to-be-asserted value can be put into the configuration, beforehand, naturally.

Copy link
Member

Choose a reason for hiding this comment

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

On a second thought, we might want to move this method to the Config class and make it public. This way the code is where it should be AND is easier testable... Let's discuss this tomorow.

@liviakuenzli liviakuenzli requested a review from ravage84 October 11, 2019 10:16
@@ -60,6 +73,7 @@ public function testDefaultConfig()
$this->assertEquals(true, $sensorConfig->getEnabled());
$this->assertEquals(2, $sensorConfig->getSeverity());
$this->assertEquals(null, $sensorConfig->getClass());
$this->assertEquals([], $sensorConfig->getSettings());
Copy link
Member

Choose a reason for hiding this comment

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

This test is fine, but I think we should test the individual methods in their own test cases, too.
I'll do that once we merged this.

@liviakuenzli liviakuenzli closed this by deleting the head repository Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make DB connection name configurable
2 participants