Passed
Push — master ( 3311dc...3c99d6 )
by Aimeos
05:26
created

lib/mshoplib/setup/unittest/LogAddTestData.php (4 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2012
6
 * @copyright Aimeos (aimeos.org), 2015-2018
7
 */
8
9
10
namespace Aimeos\MW\Setup\Task;
11
12
13
/**
14
 * Adds admin log test data.
15
 */
16
class LogAddTestData extends \Aimeos\MW\Setup\Task\Base
17
{
18
	/**
19
	 * Returns the list of task names which this task depends on.
20
	 *
21
	 * @return string[] List of task names
22
	 */
23
	public function getPreDependencies()
24
	{
25
		return ['MShopSetLocale'];
26
	}
27
28
29
	/**
30
	 * Adds admin log test data.
31
	 */
32
	public function migrate()
33
	{
34
		\Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Context\Item\Iface::class, $this->additional );
35
36
		$this->msg( 'Adding admin log test data', 0 );
37
		$this->additional->setEditor( 'core:lib/mshoplib' );
38
39
		$this->addLogTestData();
40
41
		$this->status( 'done' );
42
	}
43
44
45
	/**
46
	 * Adds the log test data.
47
	 *
48
	 * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
49
	 */
50
	private function addLogTestData()
51
	{
52
		$adminLogManager = \Aimeos\MAdmin\Log\Manager\Factory::create( $this->additional, 'Standard' );
53
54
		$ds = DIRECTORY_SEPARATOR;
55
		$path = __DIR__ . $ds . 'data' . $ds . 'log.php';
56
57
		if( ( $testdata = include( $path ) ) == false ) {
58
			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for log domain', $path ) );
59
		}
60
61
		$log = $adminLogManager->createItem();
62
63
		$adminLogManager->begin();
64
65
		foreach( $testdata['log'] as $dataset )
66
		{
67
			$log->setId( null );
68
			$log->setFacility( $dataset['facility'] );
0 ignored issues
show
The method setFacility() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

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

68
			$log->/** @scrutinizer ignore-call */ 
69
         setFacility( $dataset['facility'] );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
			$log->setPriority( $dataset['priority'] );
0 ignored issues
show
The method setPriority() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

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

69
			$log->/** @scrutinizer ignore-call */ 
70
         setPriority( $dataset['priority'] );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
			$log->setMessage( $dataset['message'] );
0 ignored issues
show
The method setMessage() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

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

70
			$log->/** @scrutinizer ignore-call */ 
71
         setMessage( $dataset['message'] );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
			$log->setRequest( $dataset['request'] );
0 ignored issues
show
The method setRequest() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

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

71
			$log->/** @scrutinizer ignore-call */ 
72
         setRequest( $dataset['request'] );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
72
73
			$adminLogManager->saveItem( $log, false );
74
		}
75
76
		$adminLogManager->commit();
77
	}
78
79
}
80