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

Added channel setter for tests #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Added channel setter for tests #51

wants to merge 3 commits into from

Conversation

chimit
Copy link

@chimit chimit commented Nov 16, 2020

Currently, there is only one way to set recipient (channel) in tests by instantiating the IncomingMessage class:

$incoming1 = new IncomingMessage('hi', $sender, $recipient, ['foo' => 'bar']);
$incoming2 = new IncomingMessage('good', $sender, $recipient, ['foo' => 'bar']);

$this->bot
    ->setUser($sender)
    ->receivesRaw($incoming1)
    ->assertQuestion('How are you?')
    ->receivesRaw($incoming2);

This PR adds an ability to make it easier through a setChannel setter:

$this->bot
    ->setUser($sender)
    ->setChannel($channel)
    ->receives('hi', ['foo' => 'bar'])
    ->assertQuestion('How are you?')
    ->receives('good', ['foo' => 'bar']);

It's really useful in conversations. Otherwise, you should instantiate IncomingMessage for every message in a conversation.

Partially solves this issue botman/botman#1218

Currently, there is only one way to set recipient (channel) in tests by instantiating the `IncomingMessage` class:

```php
$incoming1 = new IncomingMessage('hi', $sender, $recipient, ['foo' => 'bar']);
$incoming2 = new IncomingMessage('good', $sender, $recipient, ['foo' => 'bar']);

$this->bot
    ->setUser($sender)
    ->receivesRaw($incoming1)
    ->assertQuestion('How are you?')
    ->receivesRaw($incoming2);
```

This PR adds an ability to make it easier through a setter:

```php
$this->bot
    ->setUser($sender)
    ->setChannel($channel)
    ->receives('hi', ['foo' => 'bar'])
    ->assertQuestion('How are you?')
    ->receives('good', ['foo' => 'bar']);
```

It's really useful in conversations. Otherwise, you should instantiate `IncomingMessage` for every message in a conversation.
@codecov
Copy link

codecov bot commented Nov 16, 2020

Codecov Report

Base: 43.35% // Head: 43.88% // Increases project coverage by +0.53% 🎉

Coverage data is based on head (a454ec0) compared to base (1b6cf1b).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #51      +/-   ##
============================================
+ Coverage     43.35%   43.88%   +0.53%     
- Complexity       75       76       +1     
============================================
  Files            11       11              
  Lines           316      319       +3     
============================================
+ Hits            137      140       +3     
  Misses          179      179              
Impacted Files Coverage Δ
src/Testing/BotManTester.php 95.62% <100.00%> (+0.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@chimit
Copy link
Author

chimit commented Nov 6, 2021

@crynobone @mpociot any chances to get this merged?

@chimit chimit closed this Nov 6, 2021
@chimit chimit deleted the patch-1 branch November 6, 2021 05:36
@chimit chimit restored the patch-1 branch November 6, 2021 05:39
@chimit chimit reopened this Nov 6, 2021
@chimit chimit closed this by deleting the head repository Jan 12, 2023
@chimit chimit reopened this Jan 23, 2023
@chimit
Copy link
Author

chimit commented Jan 23, 2023

@christophrumpel can this tiny fix be merged?

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.

1 participant