Passed
Push — master ( 8f16ed...3311dc )
by Aimeos
10:04
created

lib/mshoplib/setup/unittest/CacheAddTestData.php (3 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2014
6
 * @copyright Aimeos (aimeos.org), 2015-2018
7
 */
8
9
10
namespace Aimeos\MW\Setup\Task;
11
12
13
/**
14
 * Adds admin cache test data.
15
 */
16
class CacheAddTestData 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 cache test data', 0 );
37
		$this->additional->setEditor( 'core:lib/mshoplib' );
38
39
		$this->addCacheTestData();
40
41
		$this->status( 'done' );
42
	}
43
44
45
	/**
46
	 * Adds the cache test data.
47
	 *
48
	 * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
49
	 */
50
	private function addCacheTestData()
51
	{
52
		$manager = \Aimeos\MAdmin\Cache\Manager\Factory::create( $this->additional, 'Standard' );
53
54
		$ds = DIRECTORY_SEPARATOR;
55
		$path = __DIR__ . $ds . 'data' . $ds . 'cache.php';
56
57
		if( ( $testdata = include( $path ) ) == false ) {
58
			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for cache domain', $path ) );
59
		}
60
61
		$item = $manager->createItem();
62
63
		foreach( $testdata['cache'] as $dataset )
64
		{
65
			$item->setId( $dataset['id'] );
66
			$item->setValue( $dataset['value'] );
0 ignored issues
show
The method setValue() 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

66
			$item->/** @scrutinizer ignore-call */ 
67
          setValue( $dataset['value'] );

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...
67
			$item->setTimeExpire( $dataset['expire'] );
0 ignored issues
show
The method setTimeExpire() 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

67
			$item->/** @scrutinizer ignore-call */ 
68
          setTimeExpire( $dataset['expire'] );

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...
68
			$item->setTags( $dataset['tags'] );
0 ignored issues
show
The method setTags() 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
			$item->/** @scrutinizer ignore-call */ 
69
          setTags( $dataset['tags'] );

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
70
			$manager->saveItem( $item, false );
71
		}
72
	}
73
74
}
75