Passed
Push — master ( 4956b8...9ed26a )
by Jean Paul
01:50
created

testCanSendToSlackChannel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php declare( strict_types=1 );
2
3
namespace Coco\SourceWatcher\Tests\Vendors\StackOverflow;
4
5
use Coco\SourceWatcher\Core\SourceWatcherException;
6
use Coco\SourceWatcher\Tests\Common\ParentTest;
7
use Coco\SourceWatcher\Vendors\StackOverflow\StackOverflowSlackCommunicator;
8
use Coco\SourceWatcher\Vendors\StackOverflow\StackOverflowWebPageSource;
9
10
/**
11
 * Class StackOverflowSlackCommunicatorTest
12
 *
13
 * @package Coco\SourceWatcher\Tests\Vendors\StackOverflow
14
 */
15
class StackOverflowSlackCommunicatorTest extends ParentTest
16
{
17
    public array $results;
18
19
    /**
20
     * @throws SourceWatcherException
21
     */
22
    public function setUp () : void
23
    {
24
        $webPageSource = new StackOverflowWebPageSource( $this->getEnvironmentVariable( "STACKOVERFLOW_FL_JOBS_PHP",
25
            null, null ) );
26
27
        $this->results = $webPageSource->getResults();
28
    }
29
30
    public function testCanNotSendToSlackChannel () : void
31
    {
32
        $communicator = new StackOverflowSlackCommunicator( $this->results );
33
        $this->assertFalse( $communicator->send() );
34
    }
35
36
    public function testCanSendToSlackChannel () : void
37
    {
38
        $communicator = new StackOverflowSlackCommunicator( $this->results );
39
        $communicator->setWebHookUrl( $this->getEnvironmentVariable( "SLACK_WEB_HOOK_PHP", null, null ) );
40
        $this->assertTrue( $communicator->send() );
41
    }
42
}
43