-
Notifications
You must be signed in to change notification settings - Fork 17
/
SessionTest.php
62 lines (50 loc) · 1.69 KB
/
SessionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
use PHPUnit\Framework\TestCase;
use ValdeirPsr\PagSeguro\Domains\Environment;
use ValdeirPsr\PagSeguro\Request\Factory;
use ValdeirPsr\PagSeguro\Request\Session;
use ValdeirPsr\PagSeguro\Exception\Auth as AuthException;
class SessionTest extends TestCase
{
/**
* @test
*/
public function newInstance()
{
$env = Environment::sandbox('pagseguro@valdeir.dev', '1234567890');
$instance = new Session($env);
$this->assertInstanceOf(Session::class, $instance);
}
/**
* @test
*/
public function generatingANewSessionWithValidDataShouldNotReturnAnError()
{
$env = Environment::sandbox('pagseguro@valdeir.dev', '');
$stub = $this->getMockBuilder(Session::class)
->setConstructorArgs([$env])
->setMethods(['buildUrl'])
->getMock();
$stub->expects($this->any())
->method('buildUrl')
->willReturn('https://f3528d51-6219-4b80-8bd3-3ab112b8094f.mock.pstmn.io/v2/sessions/valid');
$result = $stub->generate();
$this->assertNotNull($result);
}
/**
* @test
*/
public function whenEnteringInvalidCredentialsShouldReturnAnError()
{
$this->expectException(AuthException::class);
$env = Environment::sandbox('pagseguro@valdeir.dev', '');
$stub = $this->getMockBuilder(Session::class)
->setConstructorArgs([$env])
->setMethods(['buildUrl'])
->getMock();
$stub->expects($this->any())
->method('buildUrl')
->willReturn('https://f3528d51-6219-4b80-8bd3-3ab112b8094f.mock.pstmn.io/v2/sessions/invalid');
$stub->generate();
}
}