Skip to content

Commit 7495aeb

Browse files
committed
added some tests
1 parent c003ed1 commit 7495aeb

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

phpunit.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="vendor/autoload.php"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
colors="true"
8+
verbose="true"
9+
convertErrorsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertWarningsToExceptions="true"
12+
processIsolation="false"
13+
stopOnFailure="false"
14+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
15+
>
16+
<coverage>
17+
<include>
18+
<directory suffix=".php">src/</directory>
19+
</include>
20+
</coverage>
21+
<testsuites>
22+
<testsuite name="Unit">
23+
<directory suffix="Test.php">./tests/Unit</directory>
24+
</testsuite>
25+
<testsuite name="Feature">
26+
<directory suffix="Test.php">./tests/Feature</directory>
27+
</testsuite>
28+
</testsuites>
29+
<php>
30+
<env name="DB_CONNECTION" value="testing"/>
31+
<env name="APP_KEY" value="base64:endncXV6MzNqcHQwcmM1amIzczh5ZmtxdTF2MnAyaHA="/>
32+
</php>
33+
</phpunit>

tests/TestCase.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace TheHocineSaad\LaravelChargilyEPay\Tests;
4+
5+
use Illuminate\Foundation\Testing\Concerns\InteractsWithViews;
6+
use Illuminate\Support\Facades\Schema;
7+
use TheHocineSaad\LaravelChargilyEPay\LaravelChargilyEPayServiceProvider;
8+
9+
class TestCase extends \Orchestra\Testbench\TestCase
10+
{
11+
use InteractsWithViews;
12+
13+
public function setUp(): void
14+
{
15+
parent::setUp();
16+
}
17+
18+
protected function getPackageProviders($app)
19+
{
20+
return [
21+
LaravelChargilyEPayServiceProvider::class,
22+
];
23+
}
24+
25+
protected function getEnvironmentSetUp($app)
26+
{
27+
Schema::hasTable('wilayas') ?? Schema::drop('epay_invoices');
28+
29+
$migration = include __DIR__.'/../database/migrations/2999_03_11_000000_create_invoices_table.php';
30+
$migration->up();
31+
}
32+
}

tests/Unit/EpayInvoiceTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace TheHocineSaad\LaravelChargilyEPay\Tests\Unit;
4+
5+
use Illuminate\Support\Facades\Schema;
6+
use TheHocineSaad\LaravelChargilyEPay\Tests\TestCase;
7+
8+
class EpayInvoiceTest extends TestCase
9+
{
10+
public function test_if_epay_invoices_table_is_created()
11+
{
12+
$this->assertTrue(Schema::hasTable('epay_invoices'));
13+
}
14+
15+
public function test_if_epay_invoices_table_has_all_columns()
16+
{
17+
$this->assertTrue(Schema::hasColumns('epay_invoices', [
18+
'id',
19+
'client_name',
20+
'client_email',
21+
'amount',
22+
'discount',
23+
'mode',
24+
'description',
25+
'back_url',
26+
'checkout_url',
27+
'paid',
28+
'user_id',
29+
]));
30+
}
31+
}

tests/Unit/RoutesTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace TheHocineSaad\LaravelChargilyEPay\Tests\Unit;
4+
5+
use TheHocineSaad\LaravelChargilyEPay\Tests\TestCase;
6+
7+
class RoutesTest extends TestCase
8+
{
9+
public function test_if_webhook_tester_get_route_exists_and_works()
10+
{
11+
$response = $this->call('GET', route('epay_webhook_tester.get'));
12+
13+
$this->assertEquals(200, $response->status());
14+
}
15+
}

tests/Unit/ViewsTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace TheHocineSaad\LaravelChargilyEPay\Tests\Unit;
4+
5+
use TheHocineSaad\LaravelChargilyEPay\Tests\TestCase;
6+
7+
class ViewsTest extends TestCase
8+
{
9+
public function test_if_webhook_tester_view_exists()
10+
{
11+
$view = $this->view('laravel-chargily-epay::epay_webhook.test');
12+
13+
$this->assertNotNull($view);
14+
}
15+
}

0 commit comments

Comments
 (0)