-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhances test coverage #9
- Loading branch information
Showing
3 changed files
with
108 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,65 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
|
||
session_start(); | ||
|
||
/* Classes importeren */ | ||
include('Classes/User.php'); | ||
include('Classes/Template.php'); | ||
|
||
/* Includes importeren */ | ||
include('Includes/connect.php'); | ||
include('Includes/slashes.php'); | ||
|
||
/* Classes initialiseren */ | ||
$cUser = new User(); | ||
$cTPL = new Template('Templates/main.tpl'); | ||
|
||
/* Verbinding met de database maken */ | ||
connectDB(); | ||
|
||
$cTPL -> setPlace('TITEL', 'Link partners'); | ||
|
||
/* Controleren of je bent ingelogd en of je admin bent */ | ||
if(($cUser -> checkSession()) || ($cUser -> checkCookie())) | ||
{ | ||
$cTPL -> setBlock('LOGIN', 'logout'); | ||
$cTPL -> setBlock('FORUMLINKS', 'forumingelogd'); | ||
|
||
if(2047 & $cUser -> m_iPermis) | ||
{ | ||
$cTPL -> parse(); | ||
$cTPL -> setBlock('ADMIN', 'admin'); | ||
$cTPL -> setBlock('FORUMADMIN', 'forumadmin'); | ||
} | ||
} | ||
else | ||
{ | ||
$cTPL -> setBlock('LOGIN', 'login'); | ||
$cTPL -> parse(); | ||
$cTPL -> setPlace('THISPAGE', $_SERVER['PHP_SELF']); | ||
$cTPL -> setBlock('FORUMLINKS', 'forumnormaal'); | ||
} | ||
|
||
/*De pagina zelf */ | ||
$cTPL -> setFile('CONTENT', 'Templates/links.tpl'); | ||
$cTPL -> parse(); | ||
|
||
$sQuery = "SELECT linkid, link, incomming, outcomming FROM links ORDER BY link;"; | ||
if($cResult = mysql_query($sQuery)) | ||
{ | ||
$sBG = ''; | ||
while($aData = mysql_fetch_assoc($cResult)) | ||
{ | ||
if($sBG == '') | ||
{ | ||
$sBG = 'img/patroon.gif'; | ||
} | ||
else | ||
{ | ||
$sBG = ''; | ||
} | ||
$cTPL -> setBlock('LINK', 'link'); | ||
$cTPL -> parse(); | ||
|
||
$cTPL -> setPlace('ID', $aData['linkid']); | ||
$cTPL -> setPlace('LINKNAAM', $aData['link']); | ||
$cTPL -> setPlace('IN', $aData['incomming']); | ||
$cTPL -> setPlace('UIT', $aData['outcomming']); | ||
$cTPL -> setPlace('BG', $sBG); | ||
$cTPL -> parse(); | ||
} | ||
} | ||
|
||
$cTPL -> show(); | ||
?> | ||
<?php | ||
error_reporting(E_ALL & ~E_DEPRECATED); | ||
|
||
session_start(); | ||
|
||
/* Classes importeren */ | ||
include_once('Classes/User.php'); | ||
include_once('Classes/Template.php'); | ||
|
||
/* Includes importeren */ | ||
include_once('Includes/connect.php'); | ||
include_once('Includes/slashes.php'); | ||
|
||
/* Classes initialiseren */ | ||
$cUser = new User(); | ||
$cTPL = new Template('Templates/main.tpl'); | ||
|
||
/* Verbinding met de database maken */ | ||
connectDB(); | ||
|
||
$cTPL->setPlace('TITEL', 'Link partners'); | ||
|
||
/* Controleren of je bent ingelogd en of je admin bent */ | ||
if (($cUser->checkSession()) || ($cUser->checkCookie())) { | ||
$cTPL->setBlock('LOGIN', 'logout'); | ||
$cTPL->setBlock('FORUMLINKS', 'forumingelogd'); | ||
|
||
if (2047 & $cUser->m_iPermis) { | ||
$cTPL->parse(); | ||
$cTPL->setBlock('ADMIN', 'admin'); | ||
$cTPL->setBlock('FORUMADMIN', 'forumadmin'); | ||
} | ||
} else { | ||
$cTPL->setBlock('LOGIN', 'login'); | ||
$cTPL->parse(); | ||
$cTPL->setPlace('THISPAGE', $_SERVER['PHP_SELF']); | ||
$cTPL->setBlock('FORUMLINKS', 'forumnormaal'); | ||
} | ||
|
||
/*De pagina zelf */ | ||
$cTPL->setFile('CONTENT', 'Templates/links.tpl'); | ||
$cTPL->parse(); | ||
|
||
$sQuery = "SELECT linkid, link, incomming, outcomming FROM links ORDER BY link;"; | ||
if ($cResult = mysql_query($sQuery)) { | ||
$sBG = ''; | ||
while ($aData = mysql_fetch_assoc($cResult)) { | ||
if ($sBG == '') { | ||
$sBG = 'img/patroon.gif'; | ||
} else { | ||
$sBG = ''; | ||
} | ||
$cTPL->setBlock('LINK', 'link'); | ||
$cTPL->parse(); | ||
|
||
$cTPL->setPlace('ID', $aData['linkid']); | ||
$cTPL->setPlace('LINKNAAM', $aData['link']); | ||
$cTPL->setPlace('IN', $aData['incomming']); | ||
$cTPL->setPlace('UIT', $aData['outcomming']); | ||
$cTPL->setPlace('BG', $sBG); | ||
$cTPL->parse(); | ||
} | ||
} | ||
|
||
$cTPL->show(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Tests\Factories; | ||
|
||
class LinkFactory | ||
{ | ||
public static function create(\PDO $pdo, $name, $url) | ||
{ | ||
$sql = 'INSERT INTO links | ||
(link, url, incomming, outcomming) | ||
VALUES | ||
(?, ?, 0, 0)'; | ||
$query = $pdo->prepare($sql); | ||
$query->execute([ | ||
$name, $url | ||
]); | ||
|
||
return $pdo->lastInsertId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Tests\Pages; | ||
|
||
use Tests\Factories\LinkFactory; | ||
use Tests\TestCase; | ||
|
||
class LinksTestTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_shows_links() | ||
{ | ||
LinkFactory::create(self::$pdo, 'Spelcodes', 'https://spelcodes.nl'); | ||
LinkFactory::create(self::$pdo, 'Webdevils', 'https://webdevils.nl'); | ||
|
||
$page = $this->visitPage( | ||
__DIR__ . '/../../links.php' | ||
); | ||
|
||
$this->assertContains('Spelcodes', $page); | ||
$this->assertContains('Webdevils', $page); | ||
} | ||
} |