1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-13 21:52:29 +01:00
polr/tests/LinkHelperTest.php

46 lines
1.3 KiB
PHP
Raw Normal View History

2016-02-14 08:14:25 +01:00
<?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);
2016-02-14 08:14:25 +01:00
// assert that existent link ending returns true
$this->assertNotEquals(LinkHelper::linkExists($link->short_url), false);
2016-02-14 08:14:25 +01:00
// assert that nonexistent link ending returns false
$this->assertEquals(LinkHelper::linkExists('nonexistent'), false);
}
}