Skip to content

Commit 2e60145

Browse files
committed
namespace the tests, also fix issue with model config strings
1 parent 20339ec commit 2e60145

12 files changed

+31
-18
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
],
1313
"require": {
1414
"php": ">= 7.0",
15-
"illuminate/database": "^5.0",
16-
"illuminate/support": "^5.0"
15+
"illuminate/database": ">= 5.0",
16+
"illuminate/support": ">= 5.0"
1717
},
1818
"require-dev": {
1919
"orchestra/testbench": "~3.8",
@@ -28,7 +28,7 @@
2828
},
2929
"autoload-dev": {
3030
"psr-4": {
31-
"Tests\\": "tests/"
31+
"ConnerTests\\": "tests/"
3232
}
3333
},
3434
"extra": {

src/Events/TagAdded.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Conner\Tagging\Events;
1+
<?php
2+
3+
namespace Conner\Tagging\Events;
24

35
use Conner\Tagging\Model\Tagged;
46
use Conner\Tagging\Taggable;

src/Taggable.php

+16-5
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ public function scopeWithAllTags(Builder $query, $tagNames): Builder
186186
$className = $query->getModel()->getMorphClass();
187187

188188
foreach($tagNames as $tagSlug) {
189-
$tags = Tagged::query()
189+
190+
$model = TaggingUtility::taggedModelString();
191+
192+
$tags = $model::query()
190193
->where('tag_slug', TaggingUtility::normalize($tagSlug))
191194
->where('taggable_type', $className)
192195
->get()
@@ -245,7 +248,9 @@ private function addTag($tagName)
245248
$previousCount = $this->tagged()->where('tag_slug', '=', $tagSlug)->take(1)->count();
246249
if($previousCount >= 1) { return; }
247250

248-
$tagged = new Tagged([
251+
$model = TaggingUtility::taggedModelString();
252+
253+
$tagged = new $model([
249254
'tag_name' => TaggingUtility::displayize($tagName),
250255
'tag_slug' => $tagSlug,
251256
]);
@@ -286,7 +291,9 @@ private function removeSingleTag($tagName)
286291
*/
287292
public static function existingTags(): Collection
288293
{
289-
return Tagged::query()
294+
$model = TaggingUtility::taggedModelString();
295+
296+
return $model::query()
290297
->distinct()
291298
->join('tagging_tags', 'tag_slug', '=', 'tagging_tags.slug')
292299
->where('taggable_type', '=', (new static)->getMorphClass())
@@ -301,7 +308,9 @@ public static function existingTags(): Collection
301308
*/
302309
public static function existingTagsInGroups($groups): Collection
303310
{
304-
return Tagged::query()
311+
$model = TaggingUtility::taggedModelString();
312+
313+
return $model::query()
305314
->distinct()
306315
->join('tagging_tags', 'tag_slug', '=', 'tagging_tags.slug')
307316
->join('tagging_tag_groups', 'tag_group_id', '=', 'tagging_tag_groups.id')
@@ -372,7 +381,9 @@ private function assembleTagsForScoping($query, $tagNames)
372381
$tagNames = array_map($normalizer, $tagNames);
373382
$className = $query->getModel()->getMorphClass();
374383

375-
$tags = Tagged::query()
384+
$model = TaggingUtility::taggedModelString();
385+
386+
$tags = $model::query()
376387
->whereIn('tag_slug', $tagNames)
377388
->where('taggable_type', $className)
378389
->get()

tests/CommonUsageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Illuminate\Support\Collection;
66

tests/ConfigTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Model\Tag;
66

tests/EventTests.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Events\TagAdded;
66
use Conner\Tagging\Events\TagRemoved;

tests/TagGroupTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Model\Tag;
66
use Conner\Tagging\Model\TagGroup;

tests/TagTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Model\Tag;
66

tests/TaggableContractTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Contracts\TaggableContract;
66
use Conner\Tagging\Taggable;

tests/TaggedTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Model\Tagged;
66

tests/TaggingUtilityTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Model\Tag;
66
use Conner\Tagging\TaggingUtility;

tests/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests;
3+
namespace ConnerTests;
44

55
use Conner\Tagging\Contracts\TaggableContract;
66
use Conner\Tagging\Providers\TaggingServiceProvider;

0 commit comments

Comments
 (0)