Skip to content

Commit

Permalink
test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
boxfrommars committed Apr 25, 2015
1 parent 8d51f7f commit 0811d82
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 50 deletions.
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
28 changes: 3 additions & 25 deletions tests/SortableGroupTraitTest.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
<?php

require_once 'stubs/SortableEntity.php';
require_once 'stubs/SortableGroupEntity.php';
require_once 'SortableTestBase.php';

class SortableGroupTraitTest extends Orchestra\Testbench\TestCase
class SortableGroupTraitTest extends SortableTestBase
{

public function setUp()
{
parent::setUp();
$artisan = $this->app->make('artisan');
$artisan->call(
'migrate',
array(
'--database' => 'testbench',
'--path' => '../tests/migrations',
)
);

// fix for "Eloquent model events are not triggered when testing" https://github.com/laravel/framework/issues/1181
SortableEntityGroup::boot();
}

protected function getEnvironmentSetUp($app)
{
$app['path.base'] = __DIR__ . '/../src';

$app['config']->set('database.default', 'testbench');
$app['config']->set(
'database.connections.testbench',
array(
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
)
);
}

public function testGroupName()
{
$this->assertEquals('category', SortableEntityGroup::getSortableGroupField());
Expand Down
32 changes: 32 additions & 0 deletions tests/SortableTestBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

class SortableTestBase extends Orchestra\Testbench\TestCase
{
public function setUp()
{
parent::setUp();
$artisan = $this->app->make('artisan');
$artisan->call(
'migrate',
array(
'--database' => 'testbench',
'--path' => '../tests/migrations',
)
);
}

protected function getEnvironmentSetUp($app)
{
$app['path.base'] = __DIR__ . '/../src';

$app['config']->set('database.default', 'testbench');
$app['config']->set(
'database.connections.testbench',
array(
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
)
);
}
}
26 changes: 2 additions & 24 deletions tests/SortableTraitTest.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
<?php

require_once 'stubs/SortableEntity.php';
require_once 'SortableTestBase.php';

class SortableTraitTest extends Orchestra\Testbench\TestCase
class SortableTraitTest extends SortableTestBase
{

public function setUp()
{
parent::setUp();
$artisan = $this->app->make('artisan');
$artisan->call(
'migrate',
array(
'--database' => 'testbench',
'--path' => '../tests/migrations',
)
);

// fix for "Eloquent model events are not triggered when testing" https://github.com/laravel/framework/issues/1181
SortableEntity::boot();
}

protected function getEnvironmentSetUp($app)
{
$app['path.base'] = __DIR__ . '/../src';

$app['config']->set('database.default', 'testbench');
$app['config']->set(
'database.connections.testbench',
array(
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
)
);
}

public function testPositionOnCreate()
{
$entity = new SortableEntity();
Expand Down

0 comments on commit 0811d82

Please sign in to comment.