505 lines
14 KiB
PHP
505 lines
14 KiB
PHP
<?php
|
|
|
|
namespace LoretaAudit\Tests\UnitTests\App\Index;
|
|
|
|
use BRSystems\Core\Library\cDefuseCrypto\cDefuseCrypto;
|
|
use Exception;
|
|
|
|
class indexTest extends indexBase
|
|
{
|
|
public function testIndexPageDefaultAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageIndexAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<title>Zutenis | Sākums</title>',
|
|
'<h1 class="to-animate">Laipni lūgti grāmatvedības sistēmā ZUTENIS</h1>',
|
|
'<h2 class="to-animate">Atsauksmes</h2>',
|
|
'<h2>Pakalpojumi</h2>',
|
|
'<h2>Mēs esam radoši</h2>',
|
|
'<h2>Grāmatvedības sistēma</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
|
|
// Scroll param added
|
|
$this->setGet(['scroll_to' => '#fh5co-intro']);
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['Redirected to Location:'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testIndexPageRequestFileDownloadAction(): void
|
|
{
|
|
$oCry = new cDefuseCrypto();
|
|
$this->setGet([
|
|
'action' => 'file',
|
|
'f' => $oCry->encrypt(71),
|
|
'p' => true
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['Redirected to Location:'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Delete user cfg
|
|
$id = $this->cDb->_queryInsert(
|
|
'mod_articles_files',
|
|
[
|
|
'ref_id' => 0,
|
|
'file_name' => 'TRANZAKCIJU_IMPORTS.xlsx',
|
|
'file_link' => '/company/doc_logo/8412e9930cf0cc07800ffa5977ebe0e1d717374c.png',
|
|
'file_disabled' => '0',
|
|
'file_order' => 0,
|
|
'file_type' => 2,
|
|
]
|
|
);
|
|
|
|
$this->setGet([
|
|
'action' => 'file',
|
|
'f' => $oCry->encrypt($id),
|
|
'p' => false
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['File Download: /var/www/html/www/files/company/doc_logo/8412e9930cf0cc07800ffa5977ebe0e1d717374c.png'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testIndexPageContactUsAction(): void
|
|
{
|
|
$this->setGet([
|
|
'action' => 'contact_us',
|
|
'data' => '{"name":"Title","email":"test@test.lv","phone":"123456789","message":"msg"}'
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// error case
|
|
$this->setGet([
|
|
'action' => 'contact_us',
|
|
'data' => '{"name":"","message":""}'
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['"error":true,"0":"fData","1"'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testIndexPageSubscribeAction(): void
|
|
{
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => 'test@test.lv']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Case 2
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => 'test2222@test.lv']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Error Case
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => '']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"error":true,"msg":"Something went wrong!"}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Error Case 2
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => 'test@']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"error":true,"msg":"Something went wrong!"}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testIndexPageUnsubscribeAction(): void
|
|
{
|
|
$this->setGet([
|
|
'action' => 'unsubscribe',
|
|
'data' => ['sub_email' => 'test@test.lv']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Error case 1
|
|
$this->setGet([
|
|
'action' => 'unsubscribe',
|
|
'data' => ['sub_email' => 'test']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Error case 2
|
|
$this->setGet([
|
|
'action' => 'unsubscribe',
|
|
'data' => ['sub_email' => '']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageIndexAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"error":true,"msg":"Something went wrong!"}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testPageUnSubscribeDefaultAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageUnSubscribeAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h1 class="to-animate">Atcelt abonēšanu</h1>',
|
|
'<h2 class="to-animate">Kāpēc atrakstīties?</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
|
|
|
|
$this->setGet([
|
|
'action' => 'unsubscribe',
|
|
'data' => ['sub_email' => 'test@test.lv']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageUnSubscribeAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Error case 1
|
|
$this->setGet([
|
|
'action' => 'unsubscribe',
|
|
'data' => ['sub_email' => 'test']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageUnSubscribeAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
|
|
// Error case 2
|
|
$this->setGet([
|
|
'action' => 'unsubscribe',
|
|
'data' => ['sub_email' => '']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageUnSubscribeAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"error":true,"msg":"Something went wrong!"}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testPageSubscribeActionDefaultAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageSubscribeAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h1 class="to-animate">Abonēt</h1>',
|
|
'<h2 class="to-animate">Subscribe to our newsletters</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
|
|
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => 'test@test.lv']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageSubscribeAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => 'test222222@test.lv']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageSubscribeAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"jsonok":true}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Error case 1
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => 'test']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageSubscribeAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"error":true,"msg":"Something went wrong!"}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
|
|
// Error case 2
|
|
$this->setGet([
|
|
'action' => 'subscribe',
|
|
'data' => ['sub_email' => '']
|
|
]);
|
|
|
|
try {
|
|
$this->index->pageSubscribeAction();
|
|
$this->fail("Exception expected!");
|
|
} catch (Exception $error) {
|
|
$this->assertExpected(
|
|
['{"error":true,"msg":"Something went wrong!"}'],
|
|
$error->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testPageAboutUsActionDefaultAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageAboutUsAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h1 class="to-animate">Par mums</h1>',
|
|
'<h2 class="to-animate">Esam profesionāļi un pieredzējuši speciālisti ar efektīvu un izcilu darba ' .
|
|
'sniegumu, sniedzot mūsu sistēmas lietotājiem labāko risinājumu.</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
}
|
|
|
|
public function testPageFAQActionDefaultAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageFAQAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h1 class="to-animate">Biežāk uzdotie jautājumi</h1>',
|
|
'<h2 class="to-animate">Šeit jūs varat atrast dažus no mūsu bieži uzdotajiem jautājumiem</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
}
|
|
|
|
public function testAgreeToTermsAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->agreeToTermsAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h1 class="to-animate">Lietošanas noteikumi</h1>',
|
|
'<h2 class="to-animate">Spēkā no 2020. gada 1. janvāra</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
}
|
|
|
|
public function testUserActivationAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->userActivationAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<p class="fables-forth-text-color text-center">Something went wrong while activating your account!</p>'
|
|
],
|
|
$pageHTML
|
|
);
|
|
}
|
|
|
|
public function testPageDisclaimersAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageDisclaimersAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h1 class="to-animate">Atruna</h1>',
|
|
'<h2 class="to-animate">Disclaimer short description</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
}
|
|
|
|
public function testPageCopyRightsAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageCopyRightsAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h1 class="to-animate">Autortiesības</h1>',
|
|
'<h2 class="to-animate">Spēkā no 2019. gada 1. jūnija</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
}
|
|
|
|
public function testPageAccessErrorAction(): void
|
|
{
|
|
ob_start();
|
|
$this->index->pageAccessErrorAction();
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
$this->assertExpected(
|
|
[
|
|
'<h2 class="fables-second-text-color mt-3 font-30 font-weight-bold text-left" ' .
|
|
'style="margin-bottom: 15px;">Piekļuves kļūda</h2>',
|
|
],
|
|
$pageHTML
|
|
);
|
|
}
|
|
|
|
public function testBlankAction(): void
|
|
{
|
|
ob_start();
|
|
$this->assertTrue($this->index->blankAction());
|
|
$pageHTML = ob_get_contents();
|
|
ob_end_clean();
|
|
}
|
|
}
|