Completed
Push — master ( 4a002f...a1b70a )
by Ezra
13s queued 10s
created

NewsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_gets_news_by_app_id() 0 16 1
A it_gets_more_than_1_news_article_by_app_id() 0 8 1
A it_has_full_news_article_by_app_id() 0 8 3
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