NewsTest::it_gets_news_by_app_id()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
require_once('BaseTester.php');
4
5
/** @group News */
6
class NewsTest extends BaseTester {
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: artisan, be, call, seed
Loading history...
7
8
    /** @test */
9
    public function it_gets_news_by_app_id()
10
    {
11
        $newsArticle = $this->steamClient->news()->GetNewsForApp($this->appId, 1, 20);
12
13
        $this->assertObjectHasAttribute('appid', $newsArticle);
14
        $this->assertEquals($this->appId, $newsArticle->appid);
15
        $this->assertObjectHasAttribute('newsitems', $newsArticle);
16
        $this->assertGreaterThan(0, count($newsArticle->newsitems));
17
18
        $attributes = [
19
            'gid', 'title', 'url', 'is_external_url', 'author', 'contents', 'feedlabel', 'date', 'feedname'
20
        ];
21
        $this->assertObjectHasAttributes($attributes, $newsArticle->newsitems[0]);
22
23
        $this->assertTrue(strlen(strip_tags($newsArticle->newsitems[0]->contents)) <= 23);
24
    }
25
26
    /** @test */
27
    public function it_gets_more_than_1_news_article_by_app_id()
28
    {
29
        $newsArticle = $this->steamClient->news()->GetNewsForApp($this->appId);
30
31
        $this->assertGreaterThan(1, count($newsArticle->newsitems));
32
33
        return $newsArticle;
34
    }
35
36
    /**
37
     * @test
38
     *
39
     * @depends it_gets_more_than_1_news_article_by_app_id
40
     *
41
     * @param $defaultNewsCall
42
     */
43
    public function it_has_full_news_article_by_app_id($defaultNewsCall)
44
    {
45
        foreach ($defaultNewsCall->newsitems as $newsItem) {
46
            if (strlen(strip_tags($newsItem->contents)) > 0) {
47
                $this->assertGreaterThan(23, strlen(strip_tags($newsItem->contents)));
48
            }
49
        }
50
    }
51
52
}
53