mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Updated tests.
This commit is contained in:
@@ -17,10 +17,13 @@ class ChartReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testYearInOut()
|
||||
{
|
||||
// $this->be($this->user());
|
||||
// $response = $this->call('GET', '/chart/report/in-out/default/20150101/20151231/1');
|
||||
// $this->assertEquals(200, $response->status());
|
||||
$this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
|
||||
$repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
$repository->shouldReceive('spentPerMonth')->once()->andReturn([]);
|
||||
$repository->shouldReceive('earnedPerMonth')->once()->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/report/in-out/default/20150101/20151231/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,9 +31,12 @@ class ChartReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testYearInOutSummarized()
|
||||
{
|
||||
// $this->be($this->user());
|
||||
// $response = $this->call('GET', '/chart/report/in-out-sum/default/20150101/20151231/1');
|
||||
// $this->assertEquals(200, $response->status());
|
||||
$this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
|
||||
$repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
$repository->shouldReceive('spentPerMonth')->once()->andReturn([]);
|
||||
$repository->shouldReceive('earnedPerMonth')->once()->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/report/in-out-sum/default/20150101/20151231/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
|
||||
/**
|
||||
@@ -15,109 +16,239 @@ class CsvControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::columnRoles
|
||||
* @todo Implement testColumnRoles().
|
||||
*/
|
||||
public function testColumnRoles()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
|
||||
// create session data:
|
||||
$this->session($this->getSessionData());
|
||||
|
||||
$response = $this->call('GET', '/csv/column_roles');
|
||||
|
||||
$this->assertEquals(200, $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::downloadConfig
|
||||
* @todo Implement testDownloadConfig().
|
||||
*/
|
||||
public function testDownloadConfig()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->session($this->getSessionData());
|
||||
$response = $this->call('GET', '/csv/download-config');
|
||||
$this->assertEquals(200, $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::downloadConfigPage
|
||||
* @todo Implement testDownloadConfigPage().
|
||||
*/
|
||||
public function testDownloadConfigPage()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->session($this->getSessionData());
|
||||
$response = $this->call('GET', '/csv/download');
|
||||
$this->assertEquals(200, $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::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', '/csv');
|
||||
$this->assertEquals(200, $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::initialParse
|
||||
* @todo Implement testInitialParse().
|
||||
*/
|
||||
public function testInitialParse()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
// post data:
|
||||
$postData = [
|
||||
'role' => [
|
||||
0 => 'account-iban',
|
||||
1 => 'opposing-iban',
|
||||
2 => 'description',
|
||||
3 => 'date-transaction',
|
||||
4 => 'amount',
|
||||
5 => 'category-name',
|
||||
6 => 'budget-name',
|
||||
],
|
||||
'map' => [0 => 1, 1 => 1],
|
||||
];
|
||||
|
||||
// create session data:
|
||||
$this->session($this->getSessionData());
|
||||
|
||||
|
||||
$response = $this->call('POST', '/csv/initial_parse', $postData);
|
||||
// should be redirect
|
||||
$this->assertEquals(302, $response->status());
|
||||
|
||||
// should be redirected to mapping:
|
||||
$this->assertRedirectedToRoute('csv.map');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::initialParse
|
||||
*/
|
||||
public function testInitialParseNoMap()
|
||||
{
|
||||
$this->be($this->user());
|
||||
// post data:
|
||||
$postData = [
|
||||
'role' => [
|
||||
0 => 'account-iban',
|
||||
1 => 'opposing-iban',
|
||||
2 => 'description',
|
||||
3 => 'date-transaction',
|
||||
4 => 'amount',
|
||||
5 => 'category-name',
|
||||
6 => 'budget-name',
|
||||
],
|
||||
'map' => [],
|
||||
'_token' => Session::token(),
|
||||
];
|
||||
|
||||
// create session data:
|
||||
$this->session($this->getSessionData());
|
||||
|
||||
|
||||
$response = $this->call('POST', '/csv/initial_parse', $postData);
|
||||
// should be redirect
|
||||
$this->assertEquals(302, $response->status());
|
||||
|
||||
// should be redirected to download config:
|
||||
$this->assertRedirectedToRoute('csv.download-config-page');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::map
|
||||
* @todo Implement testMap().
|
||||
*/
|
||||
public function testMap()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
|
||||
$this->session($this->getSessionData());
|
||||
|
||||
$response = $this->call('GET', '/csv/map');
|
||||
$this->assertEquals(200, $response->status());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::process
|
||||
* @todo Implement testProcess().
|
||||
*/
|
||||
public function testProcess()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->session($this->getSessionData());
|
||||
$response = $this->call('GET', '/csv/process');
|
||||
$this->assertEquals(200, $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::saveMapping
|
||||
* @todo Implement testSaveMapping().
|
||||
*/
|
||||
public function testSaveMapping()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->session($this->getSessionData());
|
||||
$postData = [
|
||||
'_token' => Session::token(),
|
||||
'mapping'
|
||||
=> [0 => ['NL11XOLA6707795988' => '1',],
|
||||
1 => ['NL10TAPT8906262744' => '0', 'NL93UPSZ1261542703' => '0', 'NL86IHAL3264575116' => '0', 'NL63BKBO9993148806' => '0',
|
||||
'NL22EZVA6611573534' => '0', 'NL40KZVR5107424627' => '0', 'NL29RHEE6437366575' => '0', 'NL63IEPJ7437420074' => '0',
|
||||
'NL62HQWJ8837203470' => '0', 'NL89FPEA1494900858' => '0', 'NL76MDMU3222445567' => '0', 'NL07TDQA3309954056' => '0',
|
||||
'NL35MKIY9736938778' => '0', 'NL56DNGY5455310496' => '0', 'NL17LKFR7594179781' => '0', 'NL76UJQI9524250446' => '0',
|
||||
'NL45YTPP6157249080' => '0', 'NL46TFVH5548690248' => '0', 'NL79XZWN0846248670' => '0', 'NL52MKIO8325583045' => '0',
|
||||
'NL47YVJU4419567422' => '0', 'NL04TNIP4218080631' => '0', 'NL68SOAC3516744723' => '0', 'NL53YVTS7223912863' => '0',
|
||||
'NL40QRBS9553175317' => '0', 'NL54TZNZ2922111989' => '0', 'NL04BAGX3284775110' => '0', 'NL49LULH7261231215' => '0',
|
||||
'NL11YHMI8046080217' => '0', 'NL89BXNF2470379032' => '0', 'NL74SHGG7300113478' => '0', 'NL48ZPLO1718215436' => '0',
|
||||
'NL13BJMO5341591615' => '0', 'NL59PKVU0116767154' => '0', 'NL72BQRL1220175315' => '0', 'NL53QHDG0329036955' => '0',
|
||||
'NL48BLDJ9721843563' => '0', 'NL48BHXI9733658006' => '0', 'NL33VPSU8067103542' => '0', 'NL62UDLY8957139303' => '0',
|
||||
'NL28EDMD2653501341' => '0', 'NL92QMZD6854625548' => '0', 'NL37VSLJ0853659915' => '0', 'NL95NQHS4363870109' => '0',
|
||||
'NL81LEJP9477634344' => '0', 'NL14JYVJ1041891180' => '0', 'NL57SPBS0788124528' => '0',
|
||||
'NL96DZCO4665940223' => '2',],],];
|
||||
|
||||
$response = $this->call('POST', '/csv/save_mapping', $postData);
|
||||
|
||||
$this->assertEquals(302, $response->status());
|
||||
$this->assertRedirectedToRoute('csv.download-config-page');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\CsvController::upload
|
||||
* @todo Implement testUpload().
|
||||
*/
|
||||
public function testUpload()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
|
||||
$file = new UploadedFile(storage_path('build/test-upload.csv'), 'test-file.csv', 'text/plain', 446);
|
||||
$args = [
|
||||
'_token' => Session::token(),
|
||||
'date_format' => 'Ymd',
|
||||
'csv_import_account' => 1,
|
||||
];
|
||||
|
||||
$response = $this->call('POST', '/csv/upload', $args, [], ['csv' => $file]);
|
||||
|
||||
// csv data set:
|
||||
//$this->assertSessionHas('csv-file', 'abc');
|
||||
$this->assertSessionHas('csv-date-format', 'Ymd');
|
||||
$this->assertSessionHas('csv-has-headers', false);
|
||||
$this->assertSessionHas('csv-map', []);
|
||||
$this->assertSessionHas('csv-mapped', []);
|
||||
$this->assertSessionHas('csv-roles', []);
|
||||
$this->assertSessionHas('csv-specifix', []);
|
||||
$this->assertSessionHas('csv-import-account', 1);
|
||||
$this->assertSessionHas('csv-delimiter', ',');
|
||||
|
||||
$this->assertEquals(302, $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function createUploadedFile()
|
||||
{
|
||||
$original = storage_path('build/test-upload.csv');
|
||||
$time = '12345';
|
||||
$fileName = 'csv-upload-' . $this->user()->id . '-' . $time . '.csv.encrypted';
|
||||
$fullPath = storage_path('build') . DIRECTORY_SEPARATOR . $fileName;
|
||||
|
||||
if (!file_exists($fullPath)) {
|
||||
$content = file_get_contents($original);
|
||||
$contentEncrypted = Crypt::encrypt($content);
|
||||
file_put_contents($fullPath, $contentEncrypted);
|
||||
}
|
||||
|
||||
return $fullPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getSessionData()
|
||||
{
|
||||
return [
|
||||
'csv-file' => $this->createUploadedFile(),
|
||||
'csv-date-format' => 'Ymd',
|
||||
'csv-has-headers' => false,
|
||||
'csv-import-account' => 1,
|
||||
'csv-delimiter' => ',',
|
||||
'csv-specifix' => ['Dummy'],
|
||||
'csv-roles' => [0 => 'account-iban', 1 => 'opposing-iban', 2 => 'description', 3 => 'date-transaction', 4 => 'amount',
|
||||
5 => 'category-name', 6 => 'budget-name',],
|
||||
'csv-map' => [0 => 'account-iban', 1 => 'opposing-iban',],
|
||||
'csv-mapped' => [0 => ['NL11XOLA6707795988' => '1',], 1 => ['NL96DZCO4665940223' => '2',]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user