feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
This commit is contained in:
138
modules/system/tests/plugins/database/HasOneModelTest.php
Normal file
138
modules/system/tests/plugins/database/HasOneModelTest.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace System\Tests\Plugins\Database;
|
||||
|
||||
use System\Tests\Bootstrap\PluginTestCase;
|
||||
use Database\Tester\Models\Author;
|
||||
use Database\Tester\Models\Phone;
|
||||
use Model;
|
||||
|
||||
class HasOneModelTest extends PluginTestCase
|
||||
{
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
include_once base_path() . '/modules/system/tests/fixtures/plugins/database/tester/models/Author.php';
|
||||
include_once base_path() . '/modules/system/tests/fixtures/plugins/database/tester/models/Phone.php';
|
||||
|
||||
$this->runPluginRefreshCommand('Database.Tester');
|
||||
}
|
||||
|
||||
public function testSetRelationValue()
|
||||
{
|
||||
Model::unguard();
|
||||
$author = Author::create(['name' => 'Stevie', 'email' => 'stevie@example.com']);
|
||||
$phone1 = Phone::create(['number' => '0404040404']);
|
||||
$phone2 = Phone::create(['number' => '0505050505']);
|
||||
$phone3 = Phone::make(['number' => '0606060606']);
|
||||
Model::reguard();
|
||||
|
||||
// Set by Model object
|
||||
$author->phone = $phone1;
|
||||
$author->save();
|
||||
$this->assertEquals($author->id, $phone1->author_id);
|
||||
$this->assertEquals('0404040404', $author->phone->number);
|
||||
|
||||
// Double check
|
||||
$phone1 = Phone::find($phone1->id);
|
||||
$this->assertEquals($author->id, $phone1->author_id);
|
||||
|
||||
// Set by primary key
|
||||
$phoneId = $phone2->id;
|
||||
$author->phone = $phoneId;
|
||||
$author->save();
|
||||
$phone2 = Phone::find($phoneId);
|
||||
$this->assertEquals($author->id, $phone2->author_id);
|
||||
$this->assertEquals('0505050505', $author->phone->number);
|
||||
|
||||
// Ensure relationship is "stolen" from first model
|
||||
$phone1 = Phone::find($phone1->id);
|
||||
$this->assertNotEquals($author->id, $phone1->author_id);
|
||||
|
||||
// Nullify
|
||||
$author->phone = null;
|
||||
$author->save();
|
||||
$phone2 = Phone::find($phoneId);
|
||||
$this->assertNull($phone2->author_id);
|
||||
$this->assertNull($phone2->author);
|
||||
|
||||
// Deferred in memory
|
||||
$author->phone = $phone3;
|
||||
$this->assertEquals('0606060606', $author->phone->number);
|
||||
$this->assertEquals($author->id, $phone3->author_id);
|
||||
}
|
||||
|
||||
public function testSetRelationValueTwice()
|
||||
{
|
||||
Model::unguard();
|
||||
$author = Author::create(['name' => 'Stevie', 'email' => 'stevie@example.com']);
|
||||
$phone = Phone::create(['number' => '0505050505']);
|
||||
Model::reguard();
|
||||
|
||||
$phoneId = $phone->id;
|
||||
$author->phone = $phoneId;
|
||||
$author->save();
|
||||
|
||||
$author->phone = $phoneId;
|
||||
$author->save();
|
||||
|
||||
$phone = Phone::find($phoneId);
|
||||
$this->assertEquals($author->id, $phone->author_id);
|
||||
$this->assertEquals('0505050505', $author->phone->number);
|
||||
}
|
||||
|
||||
public function testGetRelationValue()
|
||||
{
|
||||
Model::unguard();
|
||||
$author = Author::create(['name' => 'Stevie']);
|
||||
$phone = Phone::create(['number' => '0404040404', 'author_id' => $author->id]);
|
||||
Model::reguard();
|
||||
|
||||
$this->assertEquals($phone->id, $author->getRelationValue('phone'));
|
||||
}
|
||||
|
||||
public function testDeferredBinding()
|
||||
{
|
||||
$sessionKey = uniqid('session_key', true);
|
||||
|
||||
Model::unguard();
|
||||
$author = Author::create(['name' => 'Stevie']);
|
||||
$phone = Phone::create(['number' => '0404040404']);
|
||||
Model::reguard();
|
||||
|
||||
$phoneId = $phone->id;
|
||||
|
||||
// Deferred add
|
||||
$author->phone()->add($phone, $sessionKey);
|
||||
$this->assertNull($phone->author_id);
|
||||
$this->assertNull($author->phone);
|
||||
|
||||
$this->assertEquals(0, $author->phone()->count());
|
||||
$this->assertEquals(1, $author->phone()->withDeferred($sessionKey)->count());
|
||||
|
||||
// Commit deferred
|
||||
$author->save(null, $sessionKey);
|
||||
$phone = Phone::find($phoneId);
|
||||
$this->assertEquals(1, $author->phone()->count());
|
||||
$this->assertEquals($author->id, $phone->author_id);
|
||||
$this->assertEquals('0404040404', $author->phone->number);
|
||||
|
||||
// New session
|
||||
$sessionKey = uniqid('session_key', true);
|
||||
|
||||
// Deferred remove
|
||||
$author->phone()->remove($phone, $sessionKey);
|
||||
$this->assertEquals(1, $author->phone()->count());
|
||||
$this->assertEquals(0, $author->phone()->withDeferred($sessionKey)->count());
|
||||
$this->assertEquals($author->id, $phone->author_id);
|
||||
$this->assertEquals('0404040404', $author->phone->number);
|
||||
|
||||
// Commit deferred
|
||||
$author->save(null, $sessionKey);
|
||||
$phone = Phone::find($phoneId);
|
||||
$this->assertEquals(0, $author->phone()->count());
|
||||
$this->assertNull($phone->author_id);
|
||||
$this->assertNull($author->phone);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user