[TASK] Re-work/simplify copyright header in PHP files - Part 8
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Functional / Persistence / AddTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Functional\Persistence;
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
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
19
20 class AddTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
21
22 /**
23 * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
24 */
25 protected $persistentManager;
26
27 /**
28 * @var array
29 */
30 protected $testExtensionsToLoad = array('typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example');
31
32 /**
33 * @var array
34 */
35 protected $coreExtensionsToLoad = array('extbase', 'fluid');
36
37 /**
38 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
39 */
40 protected $objectManager;
41
42 /**
43 * @var \TYPO3\CMS\Extbase\Persistence\Repository
44 */
45 protected $blogRepository;
46
47 /**
48 * Sets up this test suite.
49 */
50 public function setUp() {
51 parent::setUp();
52
53 $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
54 $this->persistentManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
55 $this->blogRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\BlogRepository');
56 }
57
58 /**
59 * @test
60 */
61 public function addSimpleObjectTest() {
62 $newBlogTitle = 'aDi1oogh';
63 $newBlog = $this->objectManager->create('ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog');
64 $newBlog->setTitle($newBlogTitle);
65
66 /** @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository $blogRepository */
67 $this->blogRepository->add($newBlog);
68 $this->persistentManager->persistAll();
69
70 $newBlogCount = $this->getDatabaseConnection()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_blog', 'title = \'' . $newBlogTitle . '\'');
71 $this->assertSame(1, $newBlogCount);
72 }
73 }