Skip to content

Commit

Permalink
feat(tests): restructure test suite and add initial feature test
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1026 committed Nov 27, 2024
1 parent 2ba4440 commit c1eb83b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 8 deletions.
18 changes: 17 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"authors": [
{
"name": "DAW Ies Montsià"
Expand All @@ -17,5 +22,16 @@
},
"require": {
"php": "^8.2"
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
23 changes: 20 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<phpunit bootstrap="tests/bootstrap.php">
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="UrbanTree Test Suite">
<directory>tests</directory>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>app</directory>
</include>
</source>
<php>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
</php>
</phpunit>
16 changes: 16 additions & 0 deletions tests/Feature/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;

class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
11 changes: 11 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Tests;

// use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use PHPUnit\Framework\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
//
}
7 changes: 5 additions & 2 deletions tests/DatabaseTest.php → tests/Unit/DatabaseTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php declare(strict_types=1);
<?php

namespace Tests\Unit;

use App\Core\Database;
use PDO;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;

#[RequiresPhpExtension('pdo_mysql')]
final class DatabaseTest extends TestCase
class DatabaseTest extends TestCase
{
protected function setUp(): void
{
Expand Down
2 changes: 0 additions & 2 deletions tests/bootstrap.php

This file was deleted.

0 comments on commit c1eb83b

Please sign in to comment.