Issues (55)

setup/unittest/CmsAddTestData.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2025
6
 */
7
8
9
namespace Aimeos\Upscheme\Task;
10
11
12
/**
13
 * Adds cms test data and all items from other domains.
14
 */
15
class CmsAddTestData extends BaseAddTestData
16
{
17
	/**
18
	 * Returns the list of task names which this task depends on.
19
	 *
20
	 * @return string[] List of task names
21
	 */
22
	public function after() : array
23
	{
24
		return ['MShopSetLocale'];
25
	}
26
27
28
	/**
29
	 * Adds cms test data.
30
	 */
31
	public function up()
32
	{
33
		$this->info( 'Adding cms test data', 'vv' );
34
		$this->context()->setEditor( 'ai-cms-grapesjs' );
0 ignored issues
show
The method context() does not exist on Aimeos\Upscheme\Task\CmsAddTestData. Since you implemented __call, 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

34
		$this->/** @scrutinizer ignore-call */ 
35
         context()->setEditor( 'ai-cms-grapesjs' );
Loading history...
35
36
		$path = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'cms.php';
37
38
		if( ( $testdata = include( $path ) ) == false ) {
39
			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for cms domain', $path ) );
40
		}
41
42
		$manager = $this->getManager( 'cms' );
43
		$manager->begin();
44
45
		foreach( $testdata['cms'] as $entry )
46
		{
47
			$item = $manager->create()->fromArray( $entry );
48
			$item = $this->addListData( $manager, $item, $entry );
49
50
			$manager->save( $item );
51
		}
52
53
		$manager->commit();
54
	}
55
}
56