-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup testing, removed some dependencies from the App namespace
- Loading branch information
vagrant
committed
Nov 11, 2022
1 parent
acd431b
commit f18c744
Showing
15 changed files
with
340 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":1,"defects":{"Warning":6,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testAdministrationRoute":3,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testModuleRegistration":5,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testConstructor":3,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testIfApiIsUnauthorized":4,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testTitleConfiguation":4},"times":{"ReinVanOyen\\Cmf\\Tests\\Component\\TextFieldTest::testName":0.12,"ReinVanOyen\\Cmf\\Tests\\Component\\TextFieldTest::test_name":0.097,"Warning":0,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testConstructor":0.114,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testAdministrationRoute":0.043,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testIfApiIsUnauthorized":0.039,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testModuleRegistration":0.005,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testTitleConfiguation":0.159,"ReinVanOyen\\Cmf\\Tests\\Component\\CmfTest::testModulesCount":0.011}} |
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,11 @@ | ||
<phpunit> | ||
<testsuites> | ||
<testsuite name="Package Tests"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="DB_CONNECTION" value="testing"/> | ||
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/> | ||
</php> | ||
</phpunit> |
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
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
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,27 @@ | ||
<?php | ||
|
||
namespace ReinVanOyen\Cmf\Tests\Component; | ||
|
||
use ReinVanOyen\Cmf\Cmf; | ||
use ReinVanOyen\Cmf\Tests\TestCase; | ||
|
||
class CmfTest extends TestCase | ||
{ | ||
public function testTitleConfiguation() | ||
{ | ||
$this->assertEquals('Test cmf', app(Cmf::class)->getTitle()); | ||
} | ||
|
||
public function testIfApiIsUnauthorized() | ||
{ | ||
$response = $this->withExceptionHandling() | ||
->get('/cmf/api/modules'); | ||
|
||
$response->assertStatus(401); | ||
} | ||
|
||
public function testModulesCount() | ||
{ | ||
$this->assertCount(1, app(Cmf::class)->getModules()); | ||
} | ||
} |
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,69 @@ | ||
<?php | ||
|
||
namespace ReinVanOyen\Cmf\Tests\Fixtures\Meta; | ||
|
||
use ReinVanOyen\Cmf\Tests\Fixtures\Models\User; | ||
use ReinVanOyen\Cmf\Components\PasswordField; | ||
use ReinVanOyen\Cmf\Components\TextField; | ||
use ReinVanOyen\Cmf\Components\TextView; | ||
use ReinVanOyen\Cmf\Meta; | ||
|
||
class UserMeta extends Meta | ||
{ | ||
/** | ||
* @var string $model | ||
*/ | ||
protected static $model = User::class; | ||
|
||
/** | ||
* @var string $title | ||
*/ | ||
protected static $title = 'name'; | ||
|
||
/** | ||
* @var array $search | ||
*/ | ||
protected static $search = [ | ||
'name', | ||
]; | ||
|
||
/** | ||
* @var array $sort | ||
*/ | ||
protected static $sort = [ | ||
'name' => 'asc', | ||
]; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public static function index(): array | ||
{ | ||
return [ | ||
TextView::make('name'), | ||
TextView::make('email'), | ||
]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public static function create(): array | ||
{ | ||
return [ | ||
TextField::make('name') | ||
->validate(['required',]), | ||
TextField::make('email')->validate(['required', 'email',]), | ||
PasswordField::make('password')->validate(['required','min:8']), | ||
]; | ||
} | ||
|
||
public static function edit(): array | ||
{ | ||
return [ | ||
TextField::make('name')->validate(['required',]), | ||
TextField::make('email')->validate(['required', 'email',]), | ||
PasswordField::make('password')->validate(['nullable','min:8',]), | ||
]; | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace ReinVanOyen\Cmf\Tests\Fixtures\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Foundation\Auth\User as Authenticatable; | ||
use Illuminate\Notifications\Notifiable; | ||
use Laravel\Sanctum\HasApiTokens; | ||
|
||
class User extends Authenticatable | ||
{ | ||
use HasApiTokens, HasFactory, Notifiable; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $fillable = [ | ||
'name', | ||
'email', | ||
'password', | ||
]; | ||
|
||
/** | ||
* The attributes that should be hidden for serialization. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $hidden = [ | ||
'password', | ||
'remember_token', | ||
]; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array<string, string> | ||
*/ | ||
protected $casts = [ | ||
'email_verified_at' => 'datetime', | ||
]; | ||
} |
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,70 @@ | ||
<?php | ||
|
||
namespace ReinVanOyen\Cmf\Tests\Fixtures\Modules; | ||
|
||
use App\Cmf\Meta\UserMeta; | ||
use ReinVanOyen\Cmf\Action\Action; | ||
use ReinVanOyen\Cmf\Action\Create; | ||
use ReinVanOyen\Cmf\Action\Delete; | ||
use ReinVanOyen\Cmf\Action\Edit; | ||
use ReinVanOyen\Cmf\Action\Index; | ||
use ReinVanOyen\Cmf\Components\Link; | ||
use ReinVanOyen\Cmf\Module; | ||
|
||
class UserModule extends Module | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
protected function title(): string | ||
{ | ||
return 'Users'; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function icon() | ||
{ | ||
return 'people'; | ||
} | ||
|
||
/** | ||
* @return Action | ||
*/ | ||
public function index(): Action | ||
{ | ||
return Index::make(UserMeta::class) | ||
->action('edit') | ||
->grid([1, 1, 0, 0,]) | ||
->header([ | ||
Link::make('New user', 'create') | ||
->style('button'), | ||
]) | ||
->search(['name',]); | ||
} | ||
|
||
/** | ||
* @return Action | ||
*/ | ||
public function create(): Action | ||
{ | ||
return Create::make(UserMeta::class); | ||
} | ||
|
||
/** | ||
* @return Action | ||
*/ | ||
public function edit(): Action | ||
{ | ||
return Edit::make(UserMeta::class); | ||
} | ||
|
||
/** | ||
* @return Action | ||
*/ | ||
public function delete(): Action | ||
{ | ||
return Delete::make(UserMeta::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,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateUsersTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('users', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('email')->unique(); | ||
$table->timestamp('email_verified_at')->nullable(); | ||
$table->string('password'); | ||
$table->rememberToken(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('users'); | ||
} | ||
} |
Oops, something went wrong.