TYPO3 CMS  TYPO3_6-2
TreeDataProviderFactoryTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $fixture;
26 
27  public function setUp() {
28  $this->fixture = new \TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory();
29  $GLOBALS['TCA'] = array();
30  $GLOBALS['TCA']['foo'] = array();
31  $GLOBALS['TCA']['foo']['ctrl'] = array();
32  $GLOBALS['TCA']['foo']['ctrl']['label'] = 'labelFoo';
33  $GLOBALS['TCA']['foo']['columns'] = array();
34  }
35 
40  return array(
41  'Empty Configuration' => array(array()),
42  'File Configuration' => array(array(
43  'internal_type' => 'file',
44  'treeConfig' => array(),
45  )),
46  'Unknown Type' => array(array(
47  'internal_type' => 'foo',
48  'treeConfig' => array(),
49  )),
50  'No foreign table' => array(array(
51  'internal_type' => 'db',
52  'treeConfig' => array(),
53  )),
54  'No tree configuration' => array(array(
55  'internal_type' => 'db',
56  'foreign_table' => 'foo',
57  )),
58  'Tree configuration not array' => array(array(
59  'internal_type' => 'db',
60  'foreign_table' => 'foo',
61  'treeConfig' => 'bar',
62  )),
63  'Tree configuration missing childer and parent field' => array(array(
64  'internal_type' => 'db',
65  'foreign_table' => 'foo',
66  'treeConfig' => array(),
67  )),
68  );
69  }
70 
77  public function factoryThrowsExceptionIfInvalidConfigurationIsGiven(array $tcaConfiguration) {
78  $this->fixture->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
79  }
80 
85  $dataProviderMockClassName = $this->getUniqueId('tx_coretest_tree_data_provider');
86  eval('class ' . $dataProviderMockClassName . ' {
87  function __construct($configuration) {
88  }
89  }');
90 
91  $tcaConfiguration = array('treeConfig' => array('dataProvider' => $dataProviderMockClassName), 'internal_type' => 'foo');
92  $dataProvider = $this->fixture->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
93 
94  $this->assertInstanceOf($dataProviderMockClassName, $dataProvider);
95  }
96 
101  $dataProviderMockClassName = $this->getUniqueId('tx_coretest_tree_data_provider');
102  $tcaConfiguration = array('treeConfig' => array('dataProvider' => $dataProviderMockClassName), 'internal_type' => 'foo');
103  $classCode = 'class ' . $dataProviderMockClassName . ' {
104  function __construct($configuration) {
105  if (!is_array($configuration)) throw new Exception(\'Failed asserting that the contructor arguments are an array\');
106  if ($configuration !== ' . var_export($tcaConfiguration, TRUE) . ') throw new Exception(\'Failed asserting that the contructor arguments are correctly passed\');
107  }
108  }';
109  eval($classCode);
110  $dataProvider = $this->fixture->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
111 
112  $this->assertInstanceOf($dataProviderMockClassName, $dataProvider);
113  }
114 }
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]