Issues (404)

tests/UserPageTest.php (2 issues)

1
<?php
2
3
class UserPageTest extends FetchPageTestCase {
4
    /**
5
     * Loads the member testing fixture.
6
     */
7
    public function getDataSet() {
8
        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/user.xml');
0 ignored issues
show
Are you sure the usage of $this->createMySQLXMLDat... '/_fixtures/user.xml') targeting TWFY_Database_TestCase::createMySQLXMLDataSet() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
9
    }
10
11
    private function fetch_page($vars) {
0 ignored issues
show
The method fetch_page() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
12
        return $this->base_fetch_page($vars, 'user');
13
    }
14
15
    private function fetch_user_page($vars = [], $page = 'user') {
16
        return $this->base_fetch_page_user($vars, '1.fbb689a0c092f5534b929d302db2c8a9', $page);
17
    }
18
19
    public function testLoginPageLoads() {
20
        $page = $this->base_fetch_page([], 'user/login');
21
        $this->assertStringContainsString('Sign in', $page);
22
    }
23
24
    public function testLoginPage() {
25
        $vars = [
26
            'email' => '[email protected]',
27
            'password' => 'password',
28
            'submitted' => 'true',
29
        ];
30
        $page = $this->base_fetch_page($vars, 'user/login');
31
        # it's a redirect which means we should get nothing
32
        # as we're using the cli version of php :(
33
        $this->assertEquals('', $page);
34
    }
35
36
    public function testUserInfoPageLoads() {
37
        $page = $this->fetch_user_page();
38
        $this->assertStringContainsString('Your details', $page);
39
        $this->assertStringContainsString('Test User', $page);
40
    }
41
42
    public function testEditUserInfo() {
43
        $page = $this->fetch_user_page(['pg' => 'edit' ]);
44
        $this->assertStringContainsString('Edit your details', $page);
45
        $this->assertStringContainsString('name="pg" value="edit"', $page);
46
        $this->assertStringContainsString('value="Test"', $page);
47
48
        $vars = [
49
            'pg' => 'edit',
50
            'user_id' => 1,
51
            'firstname' => 'Example',
52
            'lastname' => 'User',
53
            'email' => '[email protected]',
54
            'submitted' => 'true',
55
        ];
56
        $page = $this->fetch_user_page($vars);
57
        $this->assertStringContainsString('Example User', $page);
58
    }
59
}
60