forked from kokonior/PHP-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorldTest.php
46 lines (35 loc) · 1.05 KB
/
HelloWorldTest.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
<?php
class HelloWorldTest extends PHPUnit_Framework_TestCase
{
/**
* @var PDO
*/
private $pdo;
public function setUp()
{
$this->pdo = new PDO($GLOBALS['db_dsn'], $GLOBALS['db_username'], $GLOBALS['db_password']);
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->pdo->query("CREATE TABLE hello (what VARCHAR(50) NOT NULL)");
}
public function tearDown()
{
$this->pdo->query("DROP TABLE hello");
}
public function testHelloWorld()
{
$helloWorld = new HelloWorld($this->pdo);
$this->assertEquals('Hello World', $helloWorld->hello());
}
public function testHello()
{
$helloWorld = new HelloWorld($this->pdo);
$this->assertEquals('Hello Bar', $helloWorld->hello('Bar'));
}
public function testWhat()
{
$helloWorld = new HelloWorld($this->pdo);
$this->assertFalse($helloWorld->what());
$helloWorld->hello('Bar');
$this->assertEquals('Bar', $helloWorld->what());
}
}