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

lib/mshoplib/setup/unittest/JobAddTestData.php (3 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 job test data.
15
 */
16
class JobAddTestData extends \Aimeos\MW\Setup\Task\Base
17
{
18
19
	/**
20
	 * Returns the list of task names which this task depends on.
21
	 *
22
	 * @return string[] List of task names
23
	 */
24
	public function getPreDependencies()
25
	{
26
		return ['MShopSetLocale'];
27
	}
28
29
30
	/**
31
	 * Adds admin job test data.
32
	 */
33
	public function migrate()
34
	{
35
		\Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Context\Item\Iface::class, $this->additional );
36
37
		$this->msg( 'Adding admin test data', 0 );
38
		$this->additional->setEditor( 'core:lib/mshoplib' );
39
40
		$this->addJobTestData();
41
42
		$this->status( 'done' );
43
	}
44
45
46
	/**
47
	 * Adds the job test data.
48
	 *
49
	 * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
50
	 */
51
	private function addJobTestData()
52
	{
53
		$adminJobManager = \Aimeos\MAdmin\Job\Manager\Factory::create( $this->additional, 'Standard' );
54
55
		$ds = DIRECTORY_SEPARATOR;
56
		$path = __DIR__ . $ds . 'data' . $ds . 'job.php';
57
58
		if( ( $testdata = include( $path ) ) == false ) {
59
			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for job domain', $path ) );
60
		}
61
62
		$job = $adminJobManager->createItem();
63
64
		$adminJobManager->begin();
65
66
		foreach( $testdata['job'] as $dataset )
67
		{
68
			$job->setId( null );
69
			$job->setLabel( $dataset['label'] );
70
			$job->setMethod( $dataset['method'] );
0 ignored issues
show
The method setMethod() 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
			$job->/** @scrutinizer ignore-call */ 
71
         setMethod( $dataset['method'] );

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
			$job->setParameter( $dataset['parameter'] );
0 ignored issues
show
The method setParameter() 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
			$job->/** @scrutinizer ignore-call */ 
72
         setParameter( $dataset['parameter'] );

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
			$job->setResult( $dataset['result'] );
0 ignored issues
show
The method setResult() 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

72
			$job->/** @scrutinizer ignore-call */ 
73
         setResult( $dataset['result'] );

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...
73
			$job->setStatus( $dataset['status'] );
74
75
			$adminJobManager->saveItem( $job, false );
76
		}
77
78
		$adminJobManager->commit();
79
	}
80
}
81