Skip to content

Commit

Permalink
Implemented unit tests for automatic entity creation through mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed Feb 16, 2024
1 parent 80d4887 commit c4ee1e3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up(): void
//$table->tinyInteger('is_hidden')->default(0)->change();
});

Illuminate\Support\Facades\DB::statement('ALTER TABLE `attributes` MODIFY `is_hidden` tinyint(1) DEFAULT 0 NOT NULL;');
Illuminate\Support\Facades\DB::raw('ALTER TABLE `attributes` MODIFY `is_hidden` tinyint(1) DEFAULT 0 NOT NULL;');
}

/**
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<env name="DB_DATABASE" value=":memory:" />
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="MAIL_MAILER" value="array"/>
<env name="APP_URL" value="http://localhost"/>
</php>
</phpunit>
24 changes: 21 additions & 3 deletions tests/Feature/Entities/EntityTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


it('GETS all entities')
->asUser()
->withCampaign()
Expand Down Expand Up @@ -41,11 +40,30 @@
->assertStatus(200)
;

it('POSTS a new character with a mention and checks that a new entity is created')
->asUser()
->withCampaign()
->postJson('/api/1.0/campaigns/1/characters', [
'name' => fake()->name(),
'entry' => '[new:item|Mega sword]',
])
->assertStatus(201)
->assertJsonStructure([
'data' => [
'id',
'entity_id',
]
])
->assertJsonFragment(['entry_parsed' => '<a href="' . env('APP_URL') .
'/w/1/entities/1" class="entity-mention" data-entity-tags="" data-entity-type="item" data-toggle="tooltip-ajax" data-id="1" data-url="' .
env('APP_URL') . '/w/1/entities/1/tooltip">Mega sword</a>'])
;

it('Transfers entities')
->asUser()
->withCampaign()
->withCampaigns(['created_by' => 1])
->withCharacters()
->withCampaigns()
->postJson('/api/1.0/campaigns/1/transfer', [
'entities' => [1,2,3],
'campaign_id' => 2,
Expand All @@ -57,8 +75,8 @@
it('Copies entities')
->asUser()
->withCampaign()
->withCampaigns(['created_by' => 1])
->withCharacters()
->withCampaigns()
->postJson('/api/1.0/campaigns/1/transfer', [
'entities' => [1,2,3],
'campaign_id' => 2,
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/FrontCampaignTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
->assertJsonStructure([
'filters' => [
'language',
'system',
'system[]',
'is_boosted',
'is_open',
'genre'
Expand Down

0 comments on commit c4ee1e3

Please sign in to comment.