[TASK] Re-work/simplify copyright header in PHP files - Part 4
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / Category / Collection / CategoryCollectionTest.php
index a9beb0e..a17be8e 100644 (file)
@@ -1,35 +1,26 @@
 <?php
 namespace TYPO3\CMS\Core\Tests\Functional\Category\Collection;
 
-/***************************************************************
- * Copyright notice
- *
- * (c) 2012 Fabien Udriot <fabien.udriot@typo3.org>
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+/**
+ * This file is part of the TYPO3 CMS project.
  *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
  *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
  *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
- * Test case for t3lib_category_CategoryCollection
+ * Test case for \TYPO3\CMS\Core\Category\Collection\CategoryCollection
  *
  * @author Fabien Udriot <fabien.udriot@typo3.org>
  */
-class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
 
        /**
         * @var \TYPO3\CMS\Core\Category\Collection\CategoryCollection
@@ -62,11 +53,6 @@ class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        private $numberOfRecords = 5;
 
        /**
-        * @var \Tx_Phpunit_Framework
-        */
-       private $testingFramework;
-
-       /**
         * @var \TYPO3\CMS\Core\Database\DatabaseConnection
         */
        private $database;
@@ -77,8 +63,9 @@ class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @return void
         */
        public function setUp() {
-               $this->database = $GLOBALS['TYPO3_DB'];
-               $this->fixture = new \TYPO3\CMS\Core\Category\Collection\CategoryCollection($this->tableName);
+               parent::setUp();
+               $this->database = $this->getDatabaseConnection();
+               $this->fixture = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Category\\Collection\\CategoryCollection', $this->tableName);
                $this->collectionRecord = array(
                        'uid' => 0,
                        'title' => uniqid('title'),
@@ -88,29 +75,12 @@ class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $GLOBALS['TCA'][$this->tableName] = array('ctrl' => array());
                // prepare environment
                $this->createDummyTable();
-               $this->testingFramework = new \Tx_Phpunit_Framework('sys_category', array('tx_foo'));
                $this->populateDummyTable();
                $this->prepareTables();
                $this->makeRelationBetweenCategoryAndDummyTable();
        }
 
        /**
-        * Tears down this test suite.
-        *
-        * @return void
-        */
-       public function tearDown() {
-               $this->testingFramework->cleanUp();
-               // clean up environment
-               $this->dropDummyTable();
-               $this->dropDummyField();
-               unset($this->testingFramework);
-               unset($this->collectionRecord);
-               unset($this->fixture);
-               unset($this->database);
-       }
-
-       /**
         * @test
         * @covers \TYPO3\CMS\Core\Category\Collection\CategoryCollection::fromArray
         * @return void
@@ -242,7 +212,7 @@ class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        $values = array(
                                'title' => uniqid('title')
                        );
-                       $this->testingFramework->createRecord($this->tableName, $values);
+                       $this->database->exec_INSERTquery($this->tableName, $values);
                }
        }
 
@@ -256,9 +226,10 @@ class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        $values = array(
                                'uid_local' => $this->categoryUid,
                                'uid_foreign' => $index,
-                               'tablenames' => $this->tableName
+                               'tablenames' => $this->tableName,
+                               'fieldname' => 'categories'
                        );
-                       $this->testingFramework->createRecord('sys_category_record_mm', $values);
+                       $this->database->exec_INSERTquery('sys_category_record_mm', $values);
                }
        }
 
@@ -303,22 +274,7 @@ class CategoryCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        'title' => uniqid('title'),
                        'is_dummy_record' => 1
                );
-               $this->categoryUid = $this->testingFramework->createRecord('sys_category', $values);
+               $this->database->exec_INSERTquery('sys_category', $values);
+               $this->categoryUid = $this->database->sql_insert_id();
        }
-
-       /**
-        * Remove dummy record and drop field
-        *
-        * @return void
-        */
-       private function dropDummyField() {
-               $sql = 'ALTER TABLE %s DROP COLUMN is_dummy_record';
-               foreach ($this->tables as $table) {
-                       $_sql = sprintf($sql, $table);
-                       $this->database->sql_query($_sql);
-               }
-       }
-
 }
-
-?>
\ No newline at end of file