TYPO3 CMS  TYPO3_7-6
TreeDataProviderFactoryTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 
26 {
30  protected $subject;
31 
32  protected function setUp()
33  {
34  $this->subject = new TreeDataProviderFactory();
35  $GLOBALS['TCA'] = [];
36  $GLOBALS['TCA']['foo'] = [];
37  $GLOBALS['TCA']['foo']['ctrl'] = [];
38  $GLOBALS['TCA']['foo']['ctrl']['label'] = 'labelFoo';
39  $GLOBALS['TCA']['foo']['columns'] = [];
40  }
41 
46  {
47  return [
48  'Empty Configuration' => [[]],
49  'File Configuration' => [[
50  'internal_type' => 'file',
51  'treeConfig' => [],
52  ]],
53  'Unknown Type' => [[
54  'internal_type' => 'foo',
55  'treeConfig' => [],
56  ]],
57  'No foreign table' => [[
58  'internal_type' => 'db',
59  'treeConfig' => [],
60  ]],
61  'No tree configuration' => [[
62  'internal_type' => 'db',
63  'foreign_table' => 'foo',
64  ]],
65  'Tree configuration not array' => [[
66  'internal_type' => 'db',
67  'foreign_table' => 'foo',
68  'treeConfig' => 'bar',
69  ]],
70  'Tree configuration missing childer and parent field' => [[
71  'internal_type' => 'db',
72  'foreign_table' => 'foo',
73  'treeConfig' => [],
74  ]],
75  ];
76  }
77 
84  public function factoryThrowsExceptionIfInvalidConfigurationIsGiven(array $tcaConfiguration)
85  {
86  $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]);
87  }
88 
93  {
94  $dataProviderMockClassName = TreeDataProviderFixture::class;
95 
96  $tcaConfiguration = ['treeConfig' => ['dataProvider' => $dataProviderMockClassName], 'internal_type' => 'foo'];
97  $dataProvider = $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]);
98 
99  $this->assertInstanceOf($dataProviderMockClassName, $dataProvider);
100  }
101 
106  {
107  $dataProviderMockClassName = TreeDataProviderWithConfigurationFixture::class;
108 
109  $tcaConfiguration = [
110  'treeConfig' => [
111  'dataProvider' => $dataProviderMockClassName,
112  ],
113  'internal_type' => 'foo',
114  ];
115  $this->setExpectedException(\RuntimeException::class, $this->anything(), 1438875249);
116  $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]);
117  }
118 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']