Skip to content

Commit 549e102

Browse files
committed
Fixed old migration
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
1 parent d1df18d commit 549e102

File tree

8 files changed

+111
-120
lines changed

8 files changed

+111
-120
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"autoload-dev": {
2525
"psr-4": {
26-
"Tests\\": "tests/"
26+
"Lloricode\\LaravelHtmlTable\\Tests\\": "tests/"
2727
}
2828
},
2929
"extra": {

tests/BaseTest.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

tests/Models/User.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Lloricode\LaravelHtmlTable\Tests\Models;
4+
5+
6+
use Illuminate\Auth\Authenticatable;
7+
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Foundation\Auth\Access\Authorizable;
9+
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
10+
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
11+
12+
class User extends Model implements AuthorizableContract, AuthenticatableContract
13+
{
14+
use Authorizable, Authenticatable;
15+
16+
/**
17+
* The attributes that are mass assignable.
18+
*
19+
* @var array
20+
*/
21+
protected $fillable = ['email', 'name', 'slug', 'password'];
22+
23+
public $timestamps = false;
24+
25+
protected $table = 'users';
26+
}

tests/TestCase.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Lloricode\LaravelHtmlTable\Tests;
4+
5+
use Orchestra\Testbench\TestCase as Orchestra;
6+
use Illuminate\Database\Schema\Blueprint;
7+
use Lloricode\LaravelHtmlTable\Tests\Models\User;
8+
9+
class TestCase extends Orchestra
10+
{
11+
12+
public function setUp()
13+
{
14+
parent::setUp();
15+
16+
$this->setUpDatabase($this->app);
17+
}
18+
19+
/**
20+
* Set up the database.
21+
*
22+
* @param \Illuminate\Foundation\Application $app
23+
*/
24+
protected function setUpDatabase($app)
25+
{
26+
$app['db']->connection()->getSchemaBuilder()->create('users', function (Blueprint $table) {
27+
$table->increments('id');
28+
$table->string('name');
29+
$table->string('email');
30+
$table->string('slug');
31+
$table->string('password');
32+
33+
});
34+
35+
User::create([
36+
'name' => 'Orchestra',
37+
'email' => '[email protected]',
38+
'slug' => str_slug('Orchestra orchestraplatform'),
39+
'password' => \Hash::make('456'),
40+
]);
41+
User::create([
42+
'name' => 'Lloric',
43+
'email' => '[email protected]',
44+
'slug' => str_slug('Lloric Garcia'),
45+
'password' => \Hash::make('1234'),
46+
]);
47+
}
48+
49+
50+
protected function getPackageAliases($app)
51+
{
52+
return [
53+
'Table' => "Lloricode\\LaravelHtmlTable\\Facades\\LaravelHtmlTableFacade"
54+
];
55+
}
56+
57+
/**
58+
* Define environment setup.
59+
*
60+
* @param \Illuminate\Foundation\Application $app
61+
* @return void
62+
*/
63+
protected function getEnvironmentSetUp($app)
64+
{
65+
// Setup default database to use sqlite :memory:
66+
$app['config']->set('database.default', 'testbench');
67+
$app['config']->set('database.connections.testbench', [
68+
'driver' => 'sqlite',
69+
'database' => ':memory:',
70+
'prefix' => '',
71+
]);
72+
}
73+
74+
protected function getPackageProviders($app)
75+
{
76+
return ['Lloricode\LaravelHtmlTable\Providers\LaravelHtmlTableProvider'];
77+
}
78+
}

tests/UserTest.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/database/migrations/0000_00_00_000000_create_users_tables.php

Lines changed: 0 additions & 55 deletions
This file was deleted.

tests/units/TestLaravelHtmlTable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
class TestLaravelHtmlTable extends \Tests\BaseTest
3+
use Lloricode\LaravelHtmlTable\Tests\TestCase;
4+
5+
class TestLaravelHtmlTable extends TestCase
46
{
57
public function testHtmlOutputWithNoAttibutes()
68
{

tests/units/TestModel.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22

3+
use Lloricode\LaravelHtmlTable\Tests\TestCase;
34

4-
class TestModel extends \Tests\BaseTest
5+
class TestModel extends TestCase
56
{
67
public function testGenerateModel()
78
{
89
$expected = '<table border="1"><thead><tr><th>Id</th><th>Name</th><th>Email</th></tr></thead><tbody><tr><td>1</td><td>Orchestra</td><td>[email protected]</td></tr><tr><td>2</td><td>Lloric</td><td>[email protected]</td></tr></tbody></table>';
910
$generated = Table::generateModel(
1011
['Id', 'Name', 'Email'], // Column for table
11-
'Tests\UserTest' // Model
12+
'Lloricode\LaravelHtmlTable\Tests\Models\User' // Model
1213
,['id', 'name', 'email'], // Fields from model
1314
0, // Pagination Limit, if 0 all will show
1415
'border="1"' // Attributes sample js/css

0 commit comments

Comments
 (0)