This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
171 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Victorlap\Approvable\Tests; | ||
|
||
use Victorlap\Approvable\Tests\Models\UserCanApprove; | ||
use Victorlap\Approvable\Tests\Models\UserCannotApprove; | ||
|
||
class BaseTests extends TestCase | ||
{ | ||
|
||
public function testApproverCanCreate() { | ||
$user = UserCanApprove::create(['name' => 'John Doe', 'email' => 'john@doe.com']); | ||
$this->assertTrue($user->exists); | ||
} | ||
|
||
public function testRegularCanCreate() { | ||
$user = UserCannotApprove::create(['name' => 'John Doe', 'email' => 'john2@doe.com']); | ||
$this->assertTrue($user->exists); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Victorlap\Approvable\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Victorlap\Approvable\Approvable; | ||
|
||
class User extends Model | ||
{ | ||
use Approvable; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'users'; | ||
|
||
protected $fillable = ['name']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Victorlap\Approvable\Tests\Models; | ||
|
||
|
||
class UserCanApprove extends User | ||
{ | ||
protected function currentUserCanApprove() | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Victorlap\Approvable\Tests\Models; | ||
|
||
|
||
class UserCannotApprove extends User | ||
{ | ||
protected function currentUserCanApprove() | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Victorlap\Approvable\Tests; | ||
|
||
use Orchestra\Testbench\TestCase as Orchestra; | ||
use Victorlap\Approvable\ApprovableServiceProvider; | ||
|
||
class TestCase extends Orchestra | ||
{ | ||
|
||
/** | ||
* Setup the test environment. | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->artisan('migrate', ['--database' => 'testing']); | ||
} | ||
|
||
/** | ||
* Define environment setup. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* @return void | ||
*/ | ||
protected function getEnvironmentSetUp($app) | ||
{ | ||
// set up database configuration | ||
$app['config']->set('database.default', 'testing'); | ||
} | ||
|
||
/** | ||
* Get Approvable package providers. | ||
* | ||
* @return array | ||
*/ | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
TestServiceProvider::class, | ||
ApprovableServiceProvider::class, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: victor | ||
* Date: 12-2-17 | ||
* Time: 20:53 | ||
*/ | ||
|
||
namespace Victorlap\Approvable\Tests; | ||
|
||
|
||
class TestServiceProvider extends \Illuminate\Support\ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
$this->loadMigrationsFrom(realpath(__DIR__.'/database/migrations/migrations')); | ||
$this->loadMigrationsFrom(realpath(__DIR__.'/../migrations')); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/database/migrations/2014_10_12_000000_create_users_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateUsersTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('users', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('name'); | ||
$table->string('email')->unique(); | ||
$table->string('password'); | ||
$table->rememberToken(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('users'); | ||
} | ||
} |