-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiple bugs + handle item delete + add tests
Fixes #7
- Loading branch information
Showing
16 changed files
with
430 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
verbose="true"> | ||
<coverage includeUncoveredFiles="false"> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<server name="DB_CONNECTION" value="testing" /> | ||
<server name="APP_ENV" value="testing"/> | ||
<server 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,36 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
use Tests\Models\AbstractPositionModel; | ||
use Tests\Models\GroupItem; | ||
|
||
class GroupItemPositionTest extends SingleItemPositionTest | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
// Create items for different group - single item position test should contain only its own group | ||
$this->createItem('DifferentGroup', null, 2); | ||
$this->createItem('DifferentGroup', null, 2); | ||
$this->createItem('DifferentGroup', null, 2); | ||
$this->createItem('DifferentGroup', null, 2); | ||
} | ||
|
||
|
||
protected function query(): Builder | ||
{ | ||
return GroupItem::query()->where('group', 1); | ||
} | ||
|
||
protected function createItem(string $name, string $position = null, int $group = 1): AbstractPositionModel | ||
{ | ||
return GroupItem::create([ | ||
'name' => $name, | ||
'position' => $position, | ||
'group' => $group, | ||
]); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
|
||
namespace Tests\Models; | ||
|
||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Pion\Support\Eloquent\Position\Traits\PositionTrait; | ||
|
||
|
||
/** | ||
* Only for tests | ||
* @property string $name | ||
* @property int $position | ||
* @property int $group | ||
*/ | ||
abstract class AbstractPositionModel extends Model | ||
{ | ||
use PositionTrait; | ||
|
||
public $timestamps = false; | ||
|
||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace Tests\Models; | ||
|
||
|
||
/** | ||
* @property int $group | ||
*/ | ||
class GroupItem extends AbstractPositionModel | ||
{ | ||
protected $fillable = [ | ||
'name', | ||
'position', | ||
'group', | ||
]; | ||
|
||
public $positionGroup = ['group']; | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Tests\Models; | ||
|
||
|
||
class SingleItem extends AbstractPositionModel | ||
{ | ||
public $timestamps = false; | ||
protected $fillable = [ | ||
'name', | ||
'position', | ||
]; | ||
} |
Oops, something went wrong.