Skip to content

Firefly III: a personal finances manager

Expand tests

James Colee389d0f7fa09
diff --git a/tests/Api/V1/Controllers/AccountControllerTest.php b/tests/Api/V1/Controllers/AccountControllerTest.php
index 76cb8fdca0..c2b43d0fa4 100644
--- a/tests/Api/V1/Controllers/AccountControllerTest.php
+++ b/tests/Api/V1/Controllers/AccountControllerTest.php
@@ -91,7 +91,7 @@ class AccountControllerTest extends TestCase
$response = $this->get('/api/v1/accounts');
$response->assertStatus(200);
$response->assertJson(['data' => [],]);
- $response->assertJson(['meta' => ['pagination' => ['total' => 10, 'count' => 10, 'per_page' => 50, 'current_page' => 1, 'total_pages' => 1]],]);
+ $response->assertJson(['meta' => ['pagination' => ['total' => 10, 'count' => 10, 'per_page' => true, 'current_page' => 1, 'total_pages' => 1]],]);
$response->assertJson(
['links' => ['self' => true, 'first' => true, 'last' => true,],]
);
diff --git a/tests/Api/V1/Controllers/TransactionControllerTest.php b/tests/Api/V1/Controllers/TransactionControllerTest.php
index 314959ab6c..c805057870 100644
--- a/tests/Api/V1/Controllers/TransactionControllerTest.php
+++ b/tests/Api/V1/Controllers/TransactionControllerTest.php
@@ -1422,7 +1422,7 @@ class TransactionControllerTest extends TestCase
}
/**
- * Submit with existing category ID, see it reflected in output.
+ * Submit with existing category name, see it reflected in output.
*
* @covers \FireflyIII\Api\V1\Controllers\TransactionController::store
* @covers \FireflyIII\Api\V1\Requests\TransactionRequest
@@ -1598,6 +1598,57 @@ class TransactionControllerTest extends TestCase
);
}
+ /**
+ * Submit with NEW category name, see it reflected in output.
+ *
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionController::store
+ * @covers \FireflyIII\Api\V1\Requests\TransactionRequest
+ */
+ public function testSuccessStoreNewCategoryName()
+ {
+ $account = auth()->user()->accounts()->where('account_type_id', 3)->first();
+ $name = 'Some new category #' . rand(1, 1000);
+ $data = [
+ 'description' => 'Some transaction #' . rand(1, 1000),
+ 'date' => '2018-01-01',
+ 'type' => 'withdrawal',
+ 'transactions' => [
+ [
+ 'amount' => '10',
+ 'currency_id' => 1,
+ 'source_id' => $account->id,
+ 'category_name' => $name,
+ ],
+
+
+ ],
+ ];
+
+ // test API
+ $response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']);
+ $response->assertStatus(200);
+ $response->assertJson(
+ [
+ 'data' => [
+ 'type' => 'transactions',
+ 'attributes' => [
+ 'description' => $data['description'],
+ 'date' => $data['date'],
+ 'source_id' => $account->id,
+ 'source_name' => $account->name,
+ 'type' => 'Withdrawal',
+ 'source_type' => 'Asset account',
+ 'destination_name' => 'Cash account',
+ 'destination_type' => 'Cash account',
+ 'amount' => -10,
+ 'category_name' => $name,
+ ],
+ 'links' => true,
+ ],
+ ]
+ );
+ }
+
/**
* Add opposing account by name.
*
diff --git a/tests/Feature/Controllers/Transaction/SingleControllerTest.php b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
index 4e04d6a0f8..f9f357c3f5 100644
--- a/tests/Feature/Controllers/Transaction/SingleControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
@@ -112,7 +112,7 @@ class SingleControllerTest extends TestCase
// mock
$repository = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
- $repository->shouldReceive('delete')->once();
+ $repository->shouldReceive('destroy')->once();
$this->session(['transactions.delete.uri' => 'http://localhost']);
$this->be($this->user());