]> git.mxchange.org Git - friendica.git/blob - tests/src/BaseObjectTest.php
Adding unittest for empty setApp()
[friendica.git] / tests / src / BaseObjectTest.php
1 <?php
2 /**
3  * BaseObjectTest class.
4  */
5
6 namespace Friendica\Test;
7
8 use Friendica\App;
9 use Friendica\BaseObject;
10 use Friendica\Test\Util\AppMockTrait;
11 use Friendica\Test\Util\VFSTrait;
12 use PHPUnit\Framework\TestCase;
13
14 /**
15  * Tests for the BaseObject class.
16  * @runTestsInSeparateProcesses
17  * @preserveGlobalState disabled
18  */
19 class BaseObjectTest extends TestCase
20 {
21         use VFSTrait;
22         use AppMockTrait;
23
24         /**
25          * @var BaseObject
26          */
27         private $baseObject;
28
29         /**
30          * Create variables used in tests.
31          */
32         protected function setUp()
33         {
34                 $this->baseObject = new BaseObject();
35         }
36
37         /**
38          * Test the getApp() function.
39          * @return void
40          */
41         public function testGetApp()
42         {
43                 $this->setUpVfsDir();
44                 $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
45                 $this->mockApp($this->root, $configMock);
46
47                 $this->assertInstanceOf(App::class, $this->baseObject->getApp());
48         }
49
50         /**
51          * Test the setApp() function.
52          * @return void
53          */
54         public function testSetApp()
55         {
56                 $this->setUpVfsDir();
57                 $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
58                 $this->mockApp($this->root, $configMock);
59
60                 $this->assertNull($this->baseObject->setApp($this->app));
61                 $this->assertEquals($this->app, $this->baseObject->getApp());
62         }
63
64         /**
65          * Test the getApp() function without App
66          * @expectedException Friendica\Network\HTTPException\InternalServerErrorException
67          */
68         public function testGetAppFailed()
69         {
70                 BaseObject::getApp();
71         }
72 }