Test Failed
Branch develop (f16019)
by Abhishek Kumar
08:27
created

ImportExportLogTest::getEnvironmentSetUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Tests;
4
5
use Orchestra\Testbench\TestCase;
6
use Illuminate\Foundation\Testing\RefreshDatabase;
7
use Illuminate\Foundation\Testing\WithoutMiddleware;
8
use Ladybirdweb\ImportExport\Facades\ImportExportLog;
9
use Ladybirdweb\ImportExport\Models\ImportExportLog as ModelImportExportLog;
10
use Ladybirdweb\ImportExport\Models\Import;
11
12
class ImportExportLogTest extends TestCase
13
{
14
	use RefreshDatabase;
0 ignored issues
show
introduced by
The trait Illuminate\Foundation\Testing\RefreshDatabase requires some properties which are not provided by Tests\ImportExportLogTest: $connectionsToTransact, $dropViews
Loading history...
15
16
	protected $import;
17
18
	protected function getPackageProviders($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
	protected function getPackageProviders(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
	{
20
	    return ['Ladybirdweb\ImportExport\ImportExportServiceProvider'];
21
	}
22
23
    protected function getEnvironmentSetUp($app)
24
    {
25
        $app['config']->set('database.default', 'testing');
26
    }
27
28
	protected function setUp ()
29
	{
30
	    parent::setUp();
31
32
	    $this->artisan('migrate', ['--database' => 'testing']);
33
34
		$this->import = Import::create([
35
			'file' => 'imports/import-1530262997.csv',
36
			'file_rows' => 104,
37
			'db_cols' => [ 'name', 'email', 'password'],
38
			'model_map' => ['email', 'name', 'password']
39
		]);
40
	}
41
42
	/**
43
	* @test
44
	*/
45
	public function save_new_log()
46
	{
47
		$import = $this->import;
48
49
		$result = ImportExportLog::logImportError( $import, ['data' => 'this is test data'], 'This is not expected' );
0 ignored issues
show
Bug introduced by
The method logImportError() does not exist on Ladybirdweb\ImportExport\Facades\ImportExportLog. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
		/** @scrutinizer ignore-call */ 
50
  $result = ImportExportLog::logImportError( $import, ['data' => 'this is test data'], 'This is not expected' );
Loading history...
50
51
		$this->assertInstanceOf( ModelImportExportLog::class, $result );
52
	}
53
54
	/**
55
	* @test
56
	*/
57
	public function get_saved_logs()
58
	{
59
		$import = $this->import;
60
61
		$log = ImportExportLog::logImportError( $import, ['data' => 'this is test data'], 'This is not expected' );
62
63
		$log_in_db = ImportExportLog::getLogs( $log->id );
0 ignored issues
show
Bug introduced by
The method getLogs() does not exist on Ladybirdweb\ImportExport\Facades\ImportExportLog. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
		/** @scrutinizer ignore-call */ 
64
  $log_in_db = ImportExportLog::getLogs( $log->id );
Loading history...
64
65
		$this->assertInternalType( 'array', $log_in_db );
66
67
		$this->assertArrayHasKey( 'data', $log_in_db[0] );
68
69
		$this->assertArrayHasKey( 'message', $log_in_db[0] );
70
	}
71
}
72