Welcome to mirror list, hosted at ThFree Co, Russian Federation.

LinkHelperTest.php « tests - github.com/cydrobolt/polr.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 12fcab66cd4f28281a212f55291c6cc9af6ce353 (plain)
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
<?php
use App\Helpers\LinkHelper;
use App\Factories\LinkFactory;

class LinkHelperTest extends TestCase
{
    /**
     * Test LinkHelper
     *
     * @return void
     */

    public function testLinkHelperAlreadyShortened() {
        $not_short = [
            'https://google.com',
            'https://example.com/google',
            'https://cydrobolt.com',
            'http://github.com/cydrobolt/polr'
        ];

        $shortened = [
            'https://polr.me/1',
            'http://bit.ly/1PUf6Sw',
            'http://'.env('APP_ADDRESS').'/1',
            'https://goo.gl/2pSp9f'
        ];


        foreach ($not_short as $u) {
            $this->assertEquals(false, LinkHelper::checkIfAlreadyShortened($u));
        }

        foreach ($shortened as $u) {
            $this->assertEquals(true, LinkHelper::checkIfAlreadyShortened($u));
        }
    }

    public function testLinkExists() {
        $link = LinkFactory::createLink('http://example.com/ci', true, null, '127.0.0.1', false, true);
        // assert that existent link ending returns true
        $this->assertNotEquals(LinkHelper::linkExists($link->short_url), false);
        // assert that nonexistent link ending returns false
        $this->assertEquals(LinkHelper::linkExists('nonexistent'), false);
    }
}