Code Monkey home page Code Monkey logo

test-plugin's Introduction

Test Plugin

This is a UI test plugin for October CMS.

Installation Instructions

Before installing this plugin, you will need to change your minimum stability to dev with composer.

composer config minimum-stability dev

Run the following to install this plugin:

php artisan plugin:install October.Test --from=https://github.com/octobercms/test-plugin

If you already have this plugin installed and need to update the database schema, run this command:

php artisan plugin:refresh October.Test

To uninstall this plugin:

php artisan plugin:remove October.Test

Tests

The following sections are explored, tested and demonstrated along with a list of the features used:

Test 1: People

A Person "Has One" Phone (One to one relationship)

  1. Relation Controller
  2. Record Finder
  3. Proxy Form fields
  4. Date pickers
  5. Context-based Form fields

Test 2: Posts

A Post "Has Many" Comments (One to many relationship)

  1. Relation Controller
  2. Popup-based Form fields
  3. Rich Editor
  4. Dual Form Controller and List Controller
  5. HTML in comments
  6. Custom Delete workflow
  7. Repeater fields in comments popup

Test 3: Users

User "Belongs To Many" Roles (Many to many relationship)

  1. Relation Controller (Standard, Pivot data, Pivot model)
  2. Image Uploaders (Single, Multi, File, Image)
  3. Number field
  4. No click list column
  5. Custom File model
  6. Form field partial
  7. Tag List in relation mode

Test 4: Locations

  1. City "Has Many" Locations
  2. City "Belongs To" Country
  3. Location "Belongs To" Country
  4. Location "Belongs To" City

Countries

A Country "Has Many" Posts "Through" a User (Has many through relationship)

  1. Checkbox list
  2. Default form field values
  3. Field dependency and filtering
  4. Repeater fields
  5. Tabs empty with no fields
  6. Sister Countries test for related repeaters

Cities

A City "Belongs To" a Country and "Has Many" Locations.

Test 5: Reviews

  1. Reviews "Morph To" Plugins and Themes as Product (Polymorphic relationships)
  2. Meta "Morph To" Plugins and Themes as Product (Polymorphic relationships)
  3. Plugins and Themes "Morph Many" Reviews
  4. Plugins and Themes "Morph One" Meta
  5. Plugins should not create when Meta validation fails.

Test 6: Trees

  1. A Member uses a simple tree (parent-child) structure.
  2. A Category uses a simple tree structure, with sorting.
  3. A Channel uses a nested set tree structure.

Test 7: Galleries

  1. Galleries are "Morphed By Many" Posts
  2. Posts "Morph To Many" Galleries

Test 8: Pages

  1. Page "Belongs To" Layout

Test 9: Product

  1. Product

General Tests

Uncategorized tests

Attributes

An Attribute is a single generic model with many relationship types.

  1. Posts "Belong To" (Attribute) Status (general.status).
  2. Countries "Belong To Many" (Attribute) Types (general.types).

Repeater Items

  1. Relational Repeater tests

test-plugin's People

Contributors

almusamim avatar alxy avatar arekusei avatar bennothommo avatar blubcow avatar canthis avatar chvuagniaux avatar daftspunk avatar gergo85 avatar herlevsen avatar jacobdekeizer avatar jimcottrell avatar larrybarker avatar lucaszdv avatar luketowers avatar meysammahfouzi avatar mjauvin avatar munxar avatar octoberapp avatar robinbonnes avatar rubenvanerk avatar samgeorges avatar scottbedard avatar seanthepottingshed avatar ternavsky avatar tobias-kuendig avatar vicrly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

test-plugin's Issues

$attributeNames not taken in account in backend form model validation

adding this into the people model,

public $attributeManes = [
        'name' => 'People name',
    ];

then create a new people through the playground, leave the name empty and save.

Current validation message stays Name field is required

Validation message expected is People name field is required

[NEED HELP]

Fileupload Complitly DESTROYS my backend.

I was (and i'm) getting issues with the fields.yaml -> type fileupload, I already put on the$attachOne -> 'upfile' => ['System\Models\File'] but it complitly destroys my backend.

Here a prtscreen -> WITHOUT $attachOne -> 'upfile' => ['System\Models\File'] :=> http://i.imgur.com/5DA2Qra.png WITH $attachOne -> 'upfile' => ['System\Models\File'] :=> http://i.imgur.com/sJW10lW.png

[question] grabbing states from a different table in the countries demo

Hi Samuel,

Thanks a lot for the test plugin. I just found it and it's already helping me wrap my head around the internals of October (which I'm thoroughly enjoying using).

In the countries demo, where the states are populated based on the country field selection, I'm trying to figure out how to adapt the getStateOptions function to grab the list from a different table (states)?

Any ideas? Also, if you'd prefer I post this in the October forums, just let me know.

TIA,
Chris

DB missing ?

Hi,

I wanted to check how relationships are set-up but after FTP'ing and run "Plaground" October tells me:

SQLSTATE[HY000]: General error: 1 no such table: october_test_people (SQL: select count(*) as aggregate from "october_test_people")

I also see no DB available. Am i missing something?
Thanks for your anwer,

Jasper

Form widgets are not bound to popups

When trying to modify list behavior to use the recordOnClick property to execute JavaScript so a popup is rendered with a record update form, form widgets are not bound to the controller.

  1. Navigate to the test plugin
  2. Open the Posts controller
  3. Select the comments tab
  4. Click on a comment to render the popup
  5. Attempt to change the comment's post relationship using the relation widget
  6. An error is thrown:

image

I discovered this issue when trying to replicate this behavior in my own plugin but using a file upload widget. Everything works as expected with the exception that after you pick a file from the file browser and it completes uploading, the widget displays an error:
image

My code is exactly the same as the post controller's:

public function onUpdate()
    {
        $this->asExtension('FormController')->update_onSave(post('record_id'));
        return $this->listRefresh();
    }

    public function onUpdateForm()
    {       
        $this->asExtension('FormController')->update(post('record_id'));
        $this->vars['recordId'] = post('record_id');
        return $this->makePartial('update_form');
    }

Proxy fields relation id null on create.

I have an issue with proxy fields. They were working previously (in test plugin and in my own plugin) correctly but I discovered few days ago that they are not working anymore.
October build: 415
Test plugin: latest (downloaded today)

Steps

  1. Click on Create New Person
  2. Change view to Proxy Fields
  3. Fill in all the necessary data for phone proxy fields and person
  4. Create person

Expected behavior:
New Person will be created related to new Phone with all the details you have filled in.

Current behavior:

  • The new person will be create correctly
  • New phone will be created (all data will be save correctly except for person_id) but without any relation to person.
  • person_id column in october_test_phones table is saved as NULL

It works perfectly with Relation Controller, this only happens with Proxy Fields.
Is there a new method to make proxy fields work with current October build or is this a bug?

Thanks!
EDIT: It works correctly with Build 317

Image in Comment is not saved

When navigating to Posts/Comments and adding a new comment, the image is not saved to the model and can't be deleted. Otherwise the image upload works fine inside the RelationController when creating a post

Inserting pivot data fails for fields without default value

This is either a bug or a feature that everybody should be aware of. I spent several hours to figure it out because it's been documented nowhere.

Assuming we have the following pivot data:

    'roles_pivot' => [
        'October\Test\Models\Role',
        'table' => 'october_test_users_roles',
        'pivot' => ['clearance_level', 'is_executive'],
        'timestamps' => true
    ],

The clearance_level and is_executive fields can be saved into database via the RelationController, only if these fields are either nullable or have a default value:

        $table->string('clearance_level')->nullable();
        $table->boolean('is_executive')->default(false);

So the following fields won't be able to be saved into database:

        $table->string('clearance_level');
        $table->boolean('is_executive');

If this is a known issue, I think it should be documented somewhere.

Can't install on vanilla October

I just installed a fresh OctoberCMS, and then I ran the install command for this plugin.
Here is the output:

Installing Plugin: October.Test
Added Repo: https://github.com/octobercms/test-plugin
Executing: composer require october/test-plugin *

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires october/test-plugin *, found october/test-plugin[dev-radist/depends-repeater, dev-temp-for-sergei, dev-master, dev-develop] but it does not match your minimum-stability.

Reverted repo change

In Manager.php line 73:
                                          
  Failed to update composer dependencies  
                                   

Call to a member function getId() on null

Steps to replicate the problem (October build number: 380)

  1. Install the plugin
  2. Click on the Playground link (top menu)
  3. Click on the Users link (left side menu)
  4. Click on the record with ID 2 (Username: Morpheus)
  5. Click on the "Pivot data" tab
  6. Click on the "Create Role" button
  7. The following error happens:

<div id=""Call to a member function getId() on null" on line 1 of d:\projects\test-project\modules\backend\behaviors\relationcontroller\partials_manage_form.htm

Why does this happen? I need to learn how to manage many to many relationships with pivot data, but this is failing.

Installation Fails

October.Test
- v1.0.1 First version of Test Plugin
- v1.0.2 Create Test 1 Tables
- v1.0.3 Create Test 2 Tables
- v1.0.4 Create Test 3 Tables
- v1.0.5 Create Test 4 Tables
- v1.0.6 Create Test 5 Tables
- v1.0.7 Create Test 6 Tables
- v1.0.8 Create Test 7 Tables
- v1.0.9 Create Test 8 Tables
- v1.0.10 Create Test 9 Tables

In Validation.php line 338:
                                  
  The hobbies field is required.  
                                  

This happens because in the seed script, you want to insert people who do not have hobbies defined, I assume that we should remove the "required" validation from the Person model.

`dependsOn` not working for `Code Editor` and `Rich Editor` field.

Steps to reproduce:

  1. Add dependsOn: [content, content_md, content_html] to name field in \october\test\models\post\fields.yaml
  2. Fill in content in the Code Editor, Markdown Editor or Rich Editor.

Desired result:
You should see a spinner running next to the name field when you fill in content in one of the editors.

Actual result:
Only the spinner is shown after filling in content in the Markdown Editor.

`DB::transaction` in migration causes error.

When running php artisan october:migrate it results in an error:

[2021-10-01 05:48:39] local.ERROR: PDOException: There is no active transaction in C:\laragon\www\test\vendor\laravel\framework\src\Illuminate\Database\Concerns\ManagesTransactions.php:49
Stack trace:
#0 C:\laragon\www\test\vendor\laravel\framework\src\Illuminate\Database\Concerns\ManagesTransactions.php(49): PDO->commit()
#1 C:\laragon\www\test\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(349): Illuminate\Database\Connection->transaction(Object(Closure))
#2 C:\laragon\www\test\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(261): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#3 C:\laragon\www\test\plugins\october\test\updates\create_test1_tables.php(44): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)

When removing the Db::transaction(function() { }); surrounding around each migration, it works fine.

issue with relation attach event payload

in the model user.php , the __construct is listening for new relation to be attached or detached.

the issue is that the parameters attributes is always null and does not contains the pivot data as expected.

$this->bindEvent('model.relation.attach', function ($relationName, $ids, $attributes) {
            traceLog("New relation {$relationName} was created", $ids, $attributes);
        });

the log outputs:

[2023-12-29 17:06:04] local.INFO: New relation roles_pivot was created  
[2023-12-29 17:06:04] local.INFO: Array
(
    [0] => 2
)
  
[2023-12-29 17:06:04] local.INFO: Array
(
)

BUILD420 issue: Extended models in relation with pivot fields contain extended fields #3265

Issue description:
It was ok before to use an

    self::extend(
        function ($model) {
            // Implement the translatable behavior
            $model->implement[] = '@Renatio.SeoManager.Behaviors.SeoModel';
        }
    );

on a model and later to have a relation to this model with pivot fields. These extended fields were rendered in a forms models controller not from another models relation. Now together with pivot fields I have a extended fields. How to get rid of them ?

Steps to reproduce the issue:

  1. Go to https://github.com/flyingbaba/oc-test-plugin clone or download . (Should be enouth to test: go to Playground -> Trees -> Edit any Category, try to add relation to it)
  2. Don't forget plugin.php require public $require = ['Renatio.SeoManager'];
  3. updates/version.yaml - contain new record and creates new table: create_categories_countries_table.php called: october_test_categories_countries
  4. Model Country is extended with $model->implement[] = '@Renatio.SeoManager.Behaviors.SeoModel';
  5. Added default_columns.yaml to models/country/ . Used in relation_config.yaml for lists.
  6. Added new field to models/category/fields.yaml
  7. Added new partial to controllers/categories/_field_countries.htm
  8. Added relation config to controllers/categories/config_relation.yaml + added relation config to controllers/Categories.php
  9. Ready to be tested ! Issue is here: Playground -> Trees -> Edit any Category when adding any new country SEO fields are rendered.

[Question]

Is it possible to limit the nesting depth on the Reorder Channels demo? I'm thinking of a use case whereby a product belongs to a category but you want to be able to sort both products and categories in the same re-order page and would therefore require that products can only be dragged between categories. Any advice would be gratefully appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.