Skip to content

Commit

Permalink
Moved relationship-tests from src/ to tests/
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-kluge committed Mar 2, 2022
1 parent d7bd6ba commit 12ab30b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"doctrine/dbal": "^3.3",
"orchestra/testbench": "^6.23|^7.0",
"phpunit/phpunit": "^9.4",
"vimeo/psalm": "^4.12"
Expand Down
8 changes: 1 addition & 7 deletions database/migrations/create_stats_tables.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ class CreateStatsTables extends Migration
{
public function up()
{
Schema::create('stats', function (Blueprint $table) {
$table->id();
$table->timestamps();
});

Schema::create('stats_events', function (Blueprint $table) {
$table->id();

$table->string('stat_id')->nullable();
$table->string('name')->nullable();
$table->string('name');
$table->string('type');
$table->bigInteger('value');

Expand Down
2 changes: 1 addition & 1 deletion tests/StatsQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

use Carbon\Carbon;
use Spatie\Stats\DataPoint;
use Spatie\Stats\Models\Stat;
use Spatie\Stats\Models\StatsEvent;
use Spatie\Stats\StatsQuery;
use Spatie\Stats\StatsWriter;
use Spatie\Stats\Tests\Stats\CustomerStats;
use Spatie\Stats\Tests\Stats\OrderStats;
use Spatie\Stats\Tests\TestClasses\Models\Stat;

class StatsQueryTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/StatsWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Spatie\Stats\Tests;

use Carbon\Carbon;
use Spatie\Stats\Models\Stat;
use Spatie\Stats\Models\StatsEvent;
use Spatie\Stats\StatsWriter;
use Spatie\Stats\Tests\Stats\CustomerStats;
use Spatie\Stats\Tests\Stats\OrderStats;
use Spatie\Stats\Tests\TestClasses\Models\Stat;

class StatsWriterTest extends TestCase
{
Expand Down
11 changes: 11 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\Stats\Tests;

use CreateStatsTables;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Orchestra\Testbench\TestCase as Orchestra;
use Spatie\Stats\StatsServiceProvider;
Expand All @@ -29,6 +30,16 @@ public function setupDatabase()
{
include_once __DIR__.'/../database/migrations/create_stats_tables.php.stub';

$this->app['db']->connection()->getSchemaBuilder()->create('stats', function (Blueprint $table) {
$table->id();
$table->timestamps();
});

(new CreateStatsTables())->up();

$this->app['db']->connection()->getSchemaBuilder()->table('stats_events', function (Blueprint $table) {
$table->string('stat_id')->nullable()->after('id');
$table->string('name')->nullable()->change();
});
}
}
3 changes: 2 additions & 1 deletion src/Models/Stat.php → tests/TestClasses/Models/Stat.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Spatie\Stats\Models;
namespace Spatie\Stats\Tests\TestClasses\Models;

use Illuminate\Database\Eloquent\Model;
use Spatie\Stats\Models\StatsEvent;

class Stat extends Model
{
Expand Down

0 comments on commit 12ab30b

Please sign in to comment.