-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.x' into vi-translations
- Loading branch information
Showing
22 changed files
with
302 additions
and
177 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
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
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,22 @@ | ||
<?php | ||
|
||
namespace Lunar\Observers; | ||
|
||
use Lunar\Models\Discount; | ||
|
||
class DiscountObserver | ||
{ | ||
/** | ||
* Handle the Discount "deleting" event. | ||
* | ||
* @return void | ||
*/ | ||
public function deleting(Discount $discount) | ||
{ | ||
$discount->brands()->detach(); | ||
$discount->collections()->detach(); | ||
$discount->customerGroups()->detach(); | ||
$discount->purchasables()->detach(); | ||
$discount->users()->detach(); | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
tests/admin/Feature/Support/Extending/ExtendsTablePaginationTest.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,17 @@ | ||
<?php | ||
|
||
use Livewire\Livewire; | ||
|
||
uses(\Lunar\Tests\Admin\Feature\Filament\TestCase::class) | ||
->group('extending.list'); | ||
|
||
it('can list all records', function () { | ||
$this->asStaff(); | ||
|
||
$customers = \Lunar\Models\Customer::factory(30)->create(); | ||
|
||
Livewire::test(\Lunar\Admin\Filament\Resources\CustomerResource\Pages\ListCustomers::class) | ||
->set('tableRecordsPerPage', 'all') | ||
->assertCountTableRecords(30) | ||
->assertCanSeeTableRecords($customers); | ||
}); |
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,97 @@ | ||
<?php | ||
|
||
use Lunar\Admin\Support\Synthesizers\ListSynth; | ||
use Lunar\FieldTypes\ListField; | ||
|
||
uses(\Lunar\Tests\Admin\Unit\Livewire\TestCase::class) | ||
->group('support.synthesizers'); | ||
|
||
describe('list field synthesizer', function () { | ||
beforeEach(function () { | ||
$this->listSynth = Mockery::mock(ListSynth::class)->makePartial(); | ||
$this->listField = Mockery::mock(ListField::class)->makePartial(); | ||
}); | ||
|
||
test('sets a value in the list field', function () { | ||
$key = 'item1'; | ||
$value = 'Test Value'; | ||
|
||
$this->listSynth->set($this->listField, $key, $value); | ||
|
||
$result = $this->listField->getValue(); | ||
|
||
expect($result)->toBeObject() | ||
->and($result)->toHaveKey($key, $value); | ||
}); | ||
|
||
test('unsets a value from the list field', function () { | ||
$key = 'item1'; | ||
$value = 'Test Value'; | ||
|
||
$this->listField->setValue([$key => $value]); | ||
|
||
$this->listSynth->unset($this->listField, $key); | ||
|
||
$result = $this->listField->getValue(); | ||
|
||
expect($result)->toBeArray() | ||
->and($result)->not->toHaveKey($key); | ||
}); | ||
|
||
test('gets values from the list field', function () { | ||
$key = 'item1'; | ||
$value = 'Test Value'; | ||
$this->listField->setValue([$key => $value]); | ||
|
||
$result = $this->listSynth->get($this->listField, $key); | ||
|
||
expect($result)->toBeArray() | ||
->and($result)->toEqual((array) $this->listField->getValue()); | ||
}); | ||
|
||
test('dehydrates the list field correctly', function () { | ||
$this->listField->setValue(['item1' => 'Test Value']); | ||
|
||
$result = $this->listSynth->dehydrate($this->listField)[0]; | ||
|
||
expect($result)->toEqual($this->listField->getValue()); | ||
}); | ||
|
||
test('handles empty keys and values', function () { | ||
$key = ''; | ||
$value = ''; | ||
|
||
$this->listSynth->set($this->listField, $key, $value); | ||
|
||
$result = $this->listField->getValue(); | ||
|
||
expect($result)->toBeObject() | ||
->and($result)->toHaveKey($key, $value); | ||
|
||
$this->listSynth->unset($this->listField, $key); | ||
|
||
$result = $this->listField->getValue(); | ||
|
||
expect($result)->toBeArray() | ||
->and($result)->not->toHaveKey($key); | ||
}); | ||
|
||
test('handles keys and values with dot notation', function () { | ||
$key = 'key.with.dots'; | ||
$value = 'Dot.Notation.Value'; | ||
|
||
$this->listSynth->set($this->listField, $key, $value); | ||
|
||
$result = $this->listField->getValue(); | ||
|
||
expect($result)->toBeObject() | ||
->and($result)->toHaveKey($key, $value); | ||
|
||
$this->listSynth->unset($this->listField, $key); | ||
|
||
$result = $this->listField->getValue(); | ||
|
||
expect($result)->toBeArray() | ||
->and($result)->not->toHaveKey($key); | ||
}); | ||
}); |
Oops, something went wrong.