-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleTest.phpt
82 lines (54 loc) · 1.57 KB
/
ExampleTest.phpt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @testcase
*/
namespace Test;
$container = require __DIR__ . '/bootstrap.php';
use NBrowserKit\Client;
use Nette\DI\Container;
use Tester\Assert;
use Tester\TestCase;
class ExampleTest extends TestCase
{
/**
* @var Container
*/
private $container;
/**
* @var Client
*/
private $client;
function __construct(Container $container)
{
$this->container = $container;
}
function setUp()
{
$this->client = new Client;
$this->client->setContainer($this->container);
}
function testSignInWithCorrectCredentials()
{
$crawler = $this->client->request('GET', '/sign/in');
Assert::contains('#', $crawler->filter('h1')->text());
$signInForm = $crawler->selectButton('#')->form();
$signInForm['username'] = 'foo';
$signInForm['password'] = 'bar';
$crawler = $this->client->submit($signInForm);
Assert::same('/', $this->client->getRequest()->getUrl()->getPath());
Assert::contains('You have been sucessfully signed in.', $crawler->filter('.flash')->text());
}
function testSignInWithWrongCredentials()
{
$crawler = $this->client->request('GET', '/sign/in');
Assert::contains('#', $crawler->filter('h1')->text());
$signInForm = $crawler->selectButton('#')->form();
$signInForm['username'] = 'foo';
$signInForm['password'] = 'fuck';
$crawler = $this->client->submit($signInForm);
Assert::same('/sign/in', $this->client->getRequest()->getUrl()->getPath());
Assert::contains('The password is incorrect.', $crawler->filter('form .error')->text());
}
}
$test = new ExampleTest($container);
$test->run();