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

Implement null connection #31

Merged
merged 1 commit into from
Jan 9, 2018
Merged

Implement null connection #31

merged 1 commit into from
Jan 9, 2018

Conversation

GwendolenLynch
Copy link
Contributor

@GwendolenLynch GwendolenLynch commented Jan 5, 2018

  • Add Genkgo\Mail\Protocol\NullConnection class
  • Be more informative when throwing exception on unsupported scheme

Use:

ClientFactory::fromString('null://localhost/')->newClient()

Use cases:

  • Testing
  • Default set up parameters
  • Maintenance mode

Please feel very free to throw rejection, requests for changes, or merge my way. 😉

- Add Genkgo\Mail\Protocol\Smtp\NullConnection class
- Be more informative when throwing exception on unsupported scheme
- Add test coverage
@frederikbosch
Copy link
Contributor

@GawainLynch Thanks! Will look at this next week. Although I have one remark already, the NullConnection would belong in the Smtp namespace since it is dedicated to SMTP only.

@GwendolenLynch
Copy link
Contributor Author

NullConnection would belong in the Smtp namespace since it is dedicated to SMTP only.

I'm going to blame that on "Friday night" … I'll dig back into it in the morning. 👍

@frederikbosch
Copy link
Contributor

And tests for the class are missing.

@GwendolenLynch
Copy link
Contributor Author

Moved NS & added tests.

Just to note, I had left out tests on the original PR as I had (originally) copied PlainTcpConnection and that was marked with @codeCoverageIgnore … plus this is itself a test class 😉

@frederikbosch
Copy link
Contributor

Thanks. I’d love to have tests though. There is defined behaviour, which is pretty well testable. This is not the case for the PlainTcpConnection, because you will have to open a tcp connection in another thread (other php process). Therefore I marked it as ignored for code coverage.

@GwendolenLynch
Copy link
Contributor Author

Not a problem in the world for me. I'm just in the process of "getting to know how you work" … every project does things (slightly or more) different.

@frederikbosch
Copy link
Contributor

Oh, I understand completely, and I am very happy with the fact you are contributing! In terms of how I work regarding to code: as strict as possible ;)

@GwendolenLynch
Copy link
Contributor Author

Actually, on that … could you ping me via email (address on my GH profile), I have a couple of things to quickly run by you.

Copy link
Contributor

@frederikbosch frederikbosch left a comment

Choose a reason for hiding this comment

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

Few remarks.

public function it_does_nothing_when_upgrade_called(): void
{
$connection = new NullConnection();
$connection->upgrade(42);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use a constant here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


public function send(string $request): int
{
$this->setReceive($request);
Copy link
Contributor

Choose a reason for hiding this comment

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

My aversion to set is pretty big... :) I'd prefer something like pushResponseToBuffer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -224,10 +224,14 @@ public static function fromString(string $dataSourceName):ClientFactory
$components['port'] ?? 25
);
break;
case 'null':
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if we should add null:// to the client factory. A new NullConnection is not something that typically requires a factory. new Client(new NullConnection()) is not harder than ClientFactory::fromString()->newClient(). Moreover, NullConnection is typically required during testing. So there is no argument in adding it for the developer's easiness. Unless, you have sound reasons to have it in the factory, I'd say we do not add it to the factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[…] is not harder than […]

That is both fair and correct …

Unless, you have sound reasons to have it in the factory, I'd say we do not add it to the factory.

My counter — that I am only adding for historical reference — is that my aversion to inconsistency is approximate to your aversion to setters 😉

However, personal ideology shouldn't stand in the way of a practical solution … so consider it "removed" 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, and linking #10 as when that gets moving, I'll add your suggestion to the docs.

@frederikbosch frederikbosch merged commit 497a723 into genkgo:master Jan 9, 2018
@frederikbosch
Copy link
Contributor

Much obliged!

@GwendolenLynch GwendolenLynch deleted the feature/null-target branch January 9, 2018 10:19
@GwendolenLynch
Copy link
Contributor Author

A pleasure 😺

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