akaunting/tests/Feature/Common/SourcesTest.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2021-09-07 10:33:34 +03:00
<?php
namespace Tests\Feature\Common;
use App\Jobs\Setting\CreateCategory;
2022-03-02 22:18:21 +03:00
use Tests\Feature\FeatureTestCase;
2021-09-07 10:33:34 +03:00
class SourcesTest extends FeatureTestCase
{
public function testItShouldHaveAutoSource()
{
$request = $this->getRequest();
$category = $this->dispatch(new CreateCategory($request));
$this->assertDatabaseHas('categories', [
'id' => $category->id,
2021-09-10 01:05:50 +03:00
'created_from' => 'core::console',
2021-09-07 10:33:34 +03:00
]);
}
public function testItShouldHaveManualSource()
{
$request = $this->getRequest();
$request['created_from'] = 'manual';
$category = $this->dispatch(new CreateCategory($request));
$this->assertDatabaseHas('categories', [
'id' => $category->id,
'created_from' => 'manual',
]);
}
public function getRequest()
{
return [
'company_id' => $this->company->id,
'name' => $this->faker->text(15),
'type' => 'income',
'color' => $this->faker->hexColor,
'enabled' => $this->faker->boolean ? 1 : 0,
];
}
}