Test Failed
Branch develop (5056e3)
by Abhishek Kumar
05:17
created

ImportExportLogTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A get_saved_logs() 0 13 1
A save_new_log() 0 7 1
1
<?php
2
3
namespace Tests;
4
5
use Tests\TestCase;
0 ignored issues
show
Bug introduced by
The type Tests\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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;
15
16
	protected $import;
17
18
	protected function setUp ()
19
	{
20
	    parent::setUp();
21
22
		$this->import = Import::create([
23
			'file' => 'imports/import-1530262997.csv',
24
			'file_rows' => 104,
25
			'db_cols' => [ 'name', 'email', 'password'],
26
			'model_map' => ['email', 'name', 'password']
27
		]);
28
	}
29
30
	/**
31
	* @test
32
	*/
33
	public function save_new_log()
34
	{
35
		$import = $this->import;
36
37
		$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

37
		/** @scrutinizer ignore-call */ 
38
  $result = ImportExportLog::logImportError( $import, ['data' => 'this is test data'], 'This is not expected' );
Loading history...
38
39
		$this->assertInstanceOf( ModelImportExportLog::class, $result );
40
	}
41
42
	/**
43
	* @test
44
	*/
45
	public function get_saved_logs()
46
	{
47
		$import = $this->import;
48
49
		$log = ImportExportLog::logImportError( $import, ['data' => 'this is test data'], 'This is not expected' );
50
51
		$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

51
		/** @scrutinizer ignore-call */ 
52
  $log_in_db = ImportExportLog::getLogs( $log->id );
Loading history...
52
53
		$this->assertInternalType( 'array', $log_in_db );
54
55
		$this->assertArrayHasKey( 'data', $log_in_db[0] );
56
57
		$this->assertArrayHasKey( 'message', $log_in_db[0] );
58
	}
59
}
60