1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
||
5 | * @copyright Metaways Infosystems GmbH, 2012 |
||
6 | * @copyright Aimeos (aimeos.org), 2015-2022 |
||
7 | */ |
||
8 | |||
9 | |||
10 | namespace Aimeos\Upscheme\Task; |
||
11 | |||
12 | |||
13 | /** |
||
14 | * Adds media test data and all items from other domains. |
||
15 | */ |
||
16 | class MediaAddTestData extends BaseAddTestData |
||
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 after() : array |
||
24 | { |
||
25 | return ['Media', 'MShopSetLocale']; |
||
26 | } |
||
27 | |||
28 | |||
29 | /** |
||
30 | * Adds media test data. |
||
31 | */ |
||
32 | public function up() |
||
33 | { |
||
34 | $this->info( 'Adding media test data', 'vv' ); |
||
35 | $this->context()->setEditor( 'core:lib/mshoplib' ); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
36 | |||
37 | $this->process( $this->getData() ); |
||
38 | } |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Returns the test data array |
||
43 | * |
||
44 | * @return array $testdata Multi-dimensional array of test data |
||
45 | */ |
||
46 | protected function getData() |
||
47 | { |
||
48 | $path = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'media.php'; |
||
49 | |||
50 | if( ( $testdata = include( $path ) ) == false ) { |
||
51 | throw new \RuntimeException( sprintf( 'No file "%1$s" found for media domain', $path ) ); |
||
52 | } |
||
53 | |||
54 | return $testdata; |
||
55 | } |
||
56 | |||
57 | |||
58 | /** |
||
59 | * Adds the media data from the given array |
||
60 | * |
||
61 | * @param array Multi-dimensional array of test data |
||
62 | */ |
||
63 | protected function process( array $testdata ) |
||
64 | { |
||
65 | $manager = $this->getManager( 'media' ); |
||
66 | $manager->begin(); |
||
67 | |||
68 | $this->storeTypes( $testdata, ['media/type', 'media/lists/type', 'media/property/type'] ); |
||
69 | |||
70 | $manager->commit(); |
||
71 | } |
||
72 | } |
||
73 |