Issues (404)

tests/TopicsTest.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * Provides test methods for topics functionality.
5
 */
6
class TopicsTest extends FetchPageTestCase {
7
    /**
8
     * Loads the topics testing fixture.
9
     */
10
    public function getDataSet() {
11
        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/topics.xml');
0 ignored issues
show
Are you sure the usage of $this->createMySQLXMLDat.../_fixtures/topics.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...
12
    }
13
14
    private function fetch_topics_page($vars) {
15
        return $this->base_fetch_page($vars, 'topic', 'index.php', '/topic/index.php');
16
    }
17
18
    private function fetch_topic_page($vars) {
19
        return $this->base_fetch_page($vars, 'topic', 'topic.php', '/topic/topic.php');
20
    }
21
22
    public function testTopicsPage() {
23
        $page = $this->fetch_topics_page(['url' => '/topic/']);
24
        $this->assertStringContainsString('Topics', $page);
25
        $this->assertStringContainsString('NHS', $page);
26
        $this->assertStringContainsString('Welfare', $page);
27
    }
28
29
    public function testTopicPage() {
30
        $page = $this->fetch_topic_page(['topic' => 'nhs', 'url' => '/topic/nhs']);
31
        $this->assertStringContainsString('NHS', $page);
32
        $this->assertStringNotContainsString('Welfare', $page);
33
        $this->assertStringContainsString('Test Hansard SubSection', $page);
34
        $this->assertStringNotContainsString('foundation hospitals', $page);
35
        $this->assertStringNotContainsString('Sign up for email alerts', $page);
36
    }
37
38
    public function testTopicPageWithSearch() {
39
        $page = $this->fetch_topic_page(['topic' => 'welfare', 'url' => '/topic/welfare']);
40
        $this->assertStringContainsString('Welfare', $page);
41
        $this->assertStringNotContainsString('NHS', $page);
42
        $this->assertStringNotContainsString('Test Hansard SubSection', $page);
43
    }
44
45
46
    public function testTopicPageRecentVotes() {
47
        $page = $this->fetch_topic_page(['topic' => 'nhs', 'url' => '/topic/nhs']);
48
        $this->assertStringContainsString('pw-2013-01-01-1-commons">', $page);
49
        $this->assertStringContainsString('The majority of MPs  voted Agreed', $page);
50
    }
51
52
    public function testTopicPageContent() {
53
        $page = $this->fetch_topic_page(['topic' => 'nhs', 'url' => '/topic/nhs']);
54
        $this->assertStringContainsString('Test Hansard SubSection', $page);
55
    }
56
}
57