Skip to content

Commit

Permalink
Update contactPage singleton test stub
Browse files Browse the repository at this point in the history
  • Loading branch information
pboivin committed Oct 29, 2021
1 parent a6a2934 commit ad780dc
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 95 deletions.
50 changes: 25 additions & 25 deletions tests/integration/SingletonModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

namespace A17\Twill\Tests\Integration;

use App\Repositories\ContactpageRepository;
use App\Repositories\ContactPageRepository;

class SingletonModuleTest extends TestCase
{
protected $allFiles = [
'{$stubs}/singleton/2021_09_30_202102_create_contactpages_tables.php' => '{$database}/migrations/',
'{$stubs}/singleton/Contactpage.php' => '{$app}/Models/',
'{$stubs}/singleton/ContactpageController.php' => '{$app}/Http/Controllers/Admin/',
'{$stubs}/singleton/ContactpageRepository.php' => '{$app}/Repositories/',
'{$stubs}/singleton/ContactpageRequest.php' => '{$app}/Http/Requests/Admin/',
'{$stubs}/singleton/ContactpageRevision.php' => '{$app}/Models/Revisions/',
'{$stubs}/singleton/ContactpageSlug.php' => '{$app}/Models/Slugs/',
'{$stubs}/singleton/ContactpageTranslation.php' => '{$app}/Models/Translations/',
'{$stubs}/singleton/form.blade.php' => '{$resources}/views/admin/contactpages/form.blade.php',
'{$stubs}/singleton/2021_09_30_202102_create_contact_pages_tables.php' => '{$database}/migrations/',
'{$stubs}/singleton/ContactPage.php' => '{$app}/Models/',
'{$stubs}/singleton/ContactPageController.php' => '{$app}/Http/Controllers/Admin/',
'{$stubs}/singleton/ContactPageRepository.php' => '{$app}/Repositories/',
'{$stubs}/singleton/ContactPageRequest.php' => '{$app}/Http/Requests/Admin/',
'{$stubs}/singleton/ContactPageRevision.php' => '{$app}/Models/Revisions/',
'{$stubs}/singleton/ContactPageSlug.php' => '{$app}/Models/Slugs/',
'{$stubs}/singleton/ContactPageTranslation.php' => '{$app}/Models/Translations/',
'{$stubs}/singleton/form.blade.php' => '{$resources}/views/admin/contactPages/form.blade.php',
'{$stubs}/singleton/twill-navigation.php' => '{$config}/',
'{$stubs}/singleton/admin.php' => '{$base}/routes/admin.php',
];
Expand All @@ -31,9 +31,9 @@ public function setUp(): void
$this->login();
}

public function createContactpage()
public function createContactPage()
{
app(ContactpageRepository::class)->create([
app(ContactPageRepository::class)->create([
'title' => [
'en' => 'Lorem ipsum',
'fr' => 'Nullam elementum',
Expand All @@ -55,46 +55,46 @@ public function testDummy()

public function testSingletonNavigationItem()
{
$this->createContactpage();
$this->createContactPage();

$this->httpRequestAssert('/twill', 'GET');

$this->assertSee('Contact Page');

$this->assertSee('http://twill.test/twill/contactpage');
$this->assertSee('http://twill.test/twill/contactPage');
}

public function testSingletonRouteIsDefined()
{
$this->createContactpage();
$this->createContactPage();

$this->httpRequestAssert('/twill/contactpage', 'GET');
$this->httpRequestAssert('/twill/contactPage', 'GET');

$this->assertSee('This is the contactpage form');
$this->assertSee('This is the ContactPage form');
}

public function testSingletonRouteRequiresOneRecord()
{
$this->httpRequestAssert('/twill/contactpage', 'GET', [], 500);
$this->httpRequestAssert('/twill/contactPage', 'GET', [], 500);

$this->assertSee("Contactpage is missing");
$this->assertSee("ContactPage is missing");
}

public function testSingletonModuleHasNoIndex()
{
$this->createContactpage();
$this->createContactPage();

$this->httpRequestAssert('/twill/contactpages', 'GET', [], 500);
$this->httpRequestAssert('/twill/contactPages', 'GET', [], 500);

$this->assertSee('Contactpage as no index');
$this->assertSee('ContactPage as no index');
}

public function testSingletonModuleHasStandardRoutes()
{
$this->createContactpage();
$this->createContactPage();

$this->httpRequestAssert('/twill/contactpages/1/edit', 'GET');
$this->httpRequestAssert('/twill/contactPages/1/edit', 'GET');

$this->assertSee('This is the contactpage form');
$this->assertSee('This is the ContactPage form');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateContactPagesTables extends Migration
{
public function up()
{
Schema::create('contact_pages', function (Blueprint $table) {
createDefaultTableFields($table);
});

Schema::create('contact_page_translations', function (Blueprint $table) {
createDefaultTranslationsTableFields($table, 'contact_page');
$table->string('title', 200)->nullable();
$table->text('description')->nullable();
});

Schema::create('contact_page_slugs', function (Blueprint $table) {
createDefaultSlugsTableFields($table, 'contact_page');
});

Schema::create('contact_page_revisions', function (Blueprint $table) {
createDefaultRevisionsTableFields($table, 'contact_page');
});
}

public function down()
{
Schema::dropIfExists('contact_page_revisions');
Schema::dropIfExists('contact_page_translations');
Schema::dropIfExists('contact_page_slugs');
Schema::dropIfExists('contact_pages');
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use A17\Twill\Models\Behaviors\HasRevisions;
use A17\Twill\Models\Model;

class Contactpage extends Model
class ContactPage extends Model
{
use HasBlocks, HasTranslation, HasSlug, HasMedias, HasFiles, HasRevisions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use A17\Twill\Http\Controllers\Admin\SingletonModuleController as BaseModuleController;

class ContactpageController extends BaseModuleController
class ContactPageController extends BaseModuleController
{
protected $moduleName = 'contactpages';
protected $moduleName = 'contactPages';
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use A17\Twill\Repositories\Behaviors\HandleFiles;
use A17\Twill\Repositories\Behaviors\HandleRevisions;
use A17\Twill\Repositories\ModuleRepository;
use App\Models\Contactpage;
use App\Models\ContactPage;

class ContactpageRepository extends ModuleRepository
class ContactPageRepository extends ModuleRepository
{
use HandleBlocks, HandleTranslations, HandleSlugs, HandleMedias, HandleFiles, HandleRevisions;

public function __construct(Contactpage $model)
public function __construct(ContactPage $model)
{
$this->model = $model;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use A17\Twill\Http\Requests\Admin\Request;

class ContactpageRequest extends Request
class ContactPageRequest extends Request
{
public function rulesForCreate()
{
Expand Down
10 changes: 10 additions & 0 deletions tests/stubs/singleton/ContactPageRevision.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models\Revisions;

use A17\Twill\Models\Revision;

class ContactPageRevision extends Revision
{
protected $table = "contact_page_revisions";
}
10 changes: 10 additions & 0 deletions tests/stubs/singleton/ContactPageSlug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models\Slugs;

use A17\Twill\Models\Model;

class ContactPageSlug extends Model
{
protected $table = "contact_page_slugs";
}
11 changes: 11 additions & 0 deletions tests/stubs/singleton/ContactPageTranslation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Models\Translations;

use A17\Twill\Models\Model;
use App\Models\ContactPage;

class ContactPageTranslation extends Model
{
protected $baseModuleModel = ContactPage::class;
}
4 changes: 2 additions & 2 deletions tests/stubs/singleton/ContactpageRevision.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use A17\Twill\Models\Revision;

class ContactpageRevision extends Revision
class ContactPageRevision extends Revision
{
protected $table = "contactpage_revisions";
protected $table = "contact_page_revisions";
}
10 changes: 0 additions & 10 deletions tests/stubs/singleton/ContactpageSlug.php

This file was deleted.

11 changes: 0 additions & 11 deletions tests/stubs/singleton/ContactpageTranslation.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/stubs/singleton/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

use Illuminate\Support\Facades\Route;

Route::singleton('contactpage');
Route::singleton('contactPage');
2 changes: 1 addition & 1 deletion tests/stubs/singleton/form.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@extends('twill::layouts.form')

@section('contentFields')
<div>This is the contactpage form</div>
<div>This is the ContactPage form</div>
@stop
2 changes: 1 addition & 1 deletion tests/stubs/singleton/twill-navigation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'contactpage' => [
'contactPage' => [
'title' => 'Contact Page',
'singleton' => true,
],
Expand Down

0 comments on commit ad780dc

Please sign in to comment.