Skip to content

Commit

Permalink
UnitTests implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Nayjest committed Feb 25, 2016
1 parent 65978e0 commit fc5630f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ composer.phar
composer.lock
apigen.phar
phpunit.phar
build
build
*.sqlite
.env
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"source": "https://github.com/view-components/eloquent-data-processing",
Expand Down
8 changes: 8 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="'view-components/eloquent-data-processing' test suite">
<directory suffix=".php">./tests/phpunit</directory>
</testsuite>
</testsuites>
</phpunit>
13 changes: 13 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
require_once __DIR__ . '/../vendor/view-components/testing-helpers/bootstrap/bootstrap.php';
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'sqlite',
'database' => __DIR__ . '/../db.sqlite',
'prefix' => '',
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
// set timezone for timestamps etc
date_default_timezone_set('UTC');
10 changes: 10 additions & 0 deletions tests/mock/TestUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace ViewComponents\Eloquent\Test\Mock;

use Illuminate\Database\Eloquent\Model;

class TestUser extends Model
{

}
26 changes: 26 additions & 0 deletions tests/phpunit/DbTableProcessingServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace ViewComponents\Eloquent\Test;

use ViewComponents\Eloquent\EloquentProcessingService;
use ViewComponents\Eloquent\EloquentProcessorResolver;
use ViewComponents\Eloquent\Test\Mock\TestUser;
use ViewComponents\ViewComponents\Data\OperationCollection;
use ViewComponents\ViewComponents\Test\Data\AbstractProcessingServiceTest;

require __DIR__ .'/../../vendor/view-components/view-components/tests/phpunit/Data/AbstractProcessingServiceTest.php';

class DbTableProcessingServiceTest extends AbstractProcessingServiceTest
{
public function setUp()
{
$this->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();
}
}

0 comments on commit fc5630f

Please sign in to comment.