diff --git a/.gitignore b/.gitignore index dee265d..3e47431 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ composer.phar composer.lock apigen.phar phpunit.phar -build \ No newline at end of file +build +*.sqlite +.env \ No newline at end of file diff --git a/composer.json b/composer.json index 5595950..a3ca720 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,26 @@ "require": { "view-components/view-components": "*" }, + "require-dev": { + "view-components/testing-helpers":"^1.1", + "illuminate/database": "*" + }, "autoload": { "psr-4": { "ViewComponents\\Eloquent\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "ViewComponents\\Eloquent\\Test\\Mock\\": "tests/mock/", + "ViewComponents\\Eloquent\\Test\\": "tests/phpunit/" + } + }, + "scripts": { + "post-install-cmd": [ + "ViewComponents\\Eloquent\\Installer::postComposerInstall" + ] + }, "support": { "email": "mail@vitaliy.in", "source": "https://github.com/view-components/eloquent-data-processing", diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..2231f1d --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + ./tests/phpunit + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..0369987 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,13 @@ +addConnection([ + 'driver' => 'sqlite', + 'database' => __DIR__ . '/../db.sqlite', + 'prefix' => '', +]); +$capsule->setAsGlobal(); +$capsule->bootEloquent(); +// set timezone for timestamps etc +date_default_timezone_set('UTC'); \ No newline at end of file diff --git a/tests/mock/TestUser.php b/tests/mock/TestUser.php new file mode 100644 index 0000000..349a523 --- /dev/null +++ b/tests/mock/TestUser.php @@ -0,0 +1,10 @@ +data = (new TestUser())->newQuery(); + $this->operations = new OperationCollection(); + $this->service = new EloquentProcessingService( + new EloquentProcessorResolver(), + $this->operations, + $this->data + ); + $this->totalCount = (new TestUser())->newQuery()->get()->count(); + } +} \ No newline at end of file