Skip to content

Firefly III: a personal finances manager

Some new tests

James Cole935dc3ff9f7a
diff --git a/tests/acceptance/Controllers/CurrencyControllerTest.php b/tests/acceptance/Controllers/CurrencyControllerTest.php
index 1418ed53da..1864534bb8 100644
--- a/tests/acceptance/Controllers/CurrencyControllerTest.php
+++ b/tests/acceptance/Controllers/CurrencyControllerTest.php
@@ -16,97 +16,116 @@ class CurrencyControllerTest extends TestCase
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::create
- * @todo Implement testCreate().
*/
public function testCreate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->be($this->user());
+ $response = $this->call('GET', '/currency/create');
+ $this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::defaultCurrency
- * @todo Implement testDefaultCurrency().
*/
public function testDefaultCurrency()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->be($this->user());
+ $response = $this->call('GET', '/currency/default/2');
+ $this->assertEquals(302, $response->status());
+ $this->assertRedirectedToRoute('currency.index');
+ $this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::delete
- * @todo Implement testDelete().
*/
public function testDelete()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->be($this->user());
+ $response = $this->call('GET', '/currency/delete/2');
+ $this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::destroy
- * @todo Implement testDestroy().
*/
public function testDestroy()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $args = [
+ '_token' => Session::token(),
+ ];
+
+ $this->session(['currency.delete.url' => 'http://localhost/currency']);
+
+
+ $this->be($this->user());
+ $response = $this->call('POST', '/currency/destroy/3', $args);
+ $this->assertSessionHas('success');
+ $this->assertRedirectedToRoute('currency.index');
+ $this->assertEquals(302, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::edit
- * @todo Implement testEdit().
*/
public function testEdit()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->be($this->user());
+ $response = $this->call('GET', '/currency/edit/2');
+ $this->assertEquals(200, $response->status());
+
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::index
- * @todo Implement testIndex().
*/
public function testIndex()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->be($this->user());
+ $response = $this->call('GET', '/currency');
+ $this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::store
- * @todo Implement testStore().
*/
public function testStore()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->be($this->user());
+ $this->session(['currency.create.url' => 'http://localhost/currency']);
+ $args = [
+ '_token' => Session::token(),
+ 'name' => 'New Euro.',
+ 'symbol' => 'Y',
+ 'code' => 'IUY',
+ ];
+
+ $response = $this->call('POST', '/currency/store', $args);
+ $this->assertEquals(302, $response->status());
+ $this->assertSessionHas('success');
+ $this->assertRedirectedToRoute('currency.index');
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::update
- * @todo Implement testUpdate().
*/
public function testUpdate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->session(['currency.edit.url' => 'http://localhost/currency']);
+
+ $args = [
+ 'id' => 1,
+ 'name' => 'New Euro.',
+ 'symbol' => 'Y',
+ 'code' => 'IUY',
+ '_token' => Session::token(),
+ ];
+ $this->be($this->user());
+
+ $response = $this->call('POST', '/currency/update/1', $args);
+ $this->assertEquals(302, $response->status());
+ $this->assertSessionHas('success');
+ $this->assertRedirectedToRoute('currency.index');
+
}
}
diff --git a/tests/acceptance/Controllers/HelpControllerTest.php b/tests/acceptance/Controllers/HelpControllerTest.php
index 18157806bf..4200ec188c 100644
--- a/tests/acceptance/Controllers/HelpControllerTest.php
+++ b/tests/acceptance/Controllers/HelpControllerTest.php
@@ -16,13 +16,23 @@ class HelpControllerTest extends TestCase
/**
* @covers FireflyIII\Http\Controllers\HelpController::show
- * @todo Implement testShow().
*/
public function testShow()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->be($this->user());
+ $response = $this->call('GET', '/help/index');
+
+ $this->assertEquals(200, $response->status());
+ }
+
+ /**
+ * @covers FireflyIII\Http\Controllers\HelpController::show
+ */
+ public function testShowNoRoute()
+ {
+ $this->be($this->user());
+ $response = $this->call('GET', '/help/indxxex');
+
+ $this->assertEquals(200, $response->status());
}
}