X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2FApiTest.php;h=cbc6f7e0b4412a0e196e78259bd2c2d56cb5d8a8;hb=a2fb49a2b4cdaca9b938e0a750575ae502c5ec63;hp=c8443512c8a461e417b5992c383a608e35f94809;hpb=c60d85329c376abfd8f812f048cb3ad5de1f6ccf;p=friendica.git diff --git a/tests/ApiTest.php b/tests/ApiTest.php index c8443512c8..cbc6f7e0b4 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -5,12 +5,12 @@ namespace Friendica\Test; -use Friendica\App; +use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\PConfig; -use Friendica\Network\BadRequestException; +use Friendica\Core\Protocol; +use Friendica\Core\System; use Friendica\Network\HTTPException; -use Friendica\Render\FriendicaSmarty; /** * Tests for the API functions. @@ -24,14 +24,11 @@ class ApiTest extends DatabaseTest /** * Create variables used by tests. */ - protected function setUp() + public function setUp() { - global $a; parent::setUp(); - // Reusable App object - $this->app = new App(__DIR__.'/../'); - $a = $this->app; + require_once __DIR__.'/../include/api.php'; // User data that the test database is populated with $this->selfUser = [ @@ -71,6 +68,18 @@ class ApiTest extends DatabaseTest Config::set('system', 'theme', 'system_theme'); } + /** + * Cleanup variables used by tests. + */ + protected function tearDown() + { + parent::tearDown(); + + $app = get_app(); + $app->argc = 1; + $app->argv = ['home']; + } + /** * Assert that an user array contains expected keys. * @param array $user User array @@ -719,10 +728,10 @@ class ApiTest extends DatabaseTest */ public function testApiGetUserWithCustomFrioSchema() { - PConfig::set($this->selfUser['id'], 'frio', 'schema', '---'); - PConfig::set($this->selfUser['id'], 'frio', 'nav_bg', '#123456'); - PConfig::set($this->selfUser['id'], 'frio', 'link_color', '#123456'); - PConfig::set($this->selfUser['id'], 'frio', 'background_color', '#123456'); + $ret1 = PConfig::set($this->selfUser['id'], 'frio', 'schema', '---'); + $ret2 = PConfig::set($this->selfUser['id'], 'frio', 'nav_bg', '#123456'); + $ret3 = PConfig::set($this->selfUser['id'], 'frio', 'link_color', '#123456'); + $ret4 = PConfig::set($this->selfUser['id'], 'frio', 'background_color', '#123456'); $user = api_get_user($this->app); $this->assertSelfUser($user); $this->assertEquals('123456', $user['profile_sidebar_fill_color']); @@ -1205,7 +1214,8 @@ class ApiTest extends DatabaseTest { $_FILES = [ 'media' => [ - 'id' => 666 + 'id' => 666, + 'tmp_name' => 'tmp_name' ] ]; api_media_upload(); @@ -2164,7 +2174,7 @@ class ApiTest extends DatabaseTest public function testApiFormatItemsEmbededImages() { $this->assertEquals( - 'text ' . \Friendica\Core\System::baseUrl() . '/display/item_guid', + 'text ' . System::baseUrl() . '/display/item_guid', api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo') ); } @@ -2338,7 +2348,7 @@ class ApiTest extends DatabaseTest 'body' => '', 'verb' => '', 'author-id' => 43, - 'author-network' => \Friendica\Core\Protocol::DFRN, + 'author-network' => Protocol::DFRN, 'author-link' => 'http://localhost/profile/othercontact', 'plink' => '', ] @@ -2361,7 +2371,7 @@ class ApiTest extends DatabaseTest 'body' => '', 'verb' => '', 'author-id' => 43, - 'author-network' => \Friendica\Core\Protocol::DFRN, + 'author-network' => Protocol::DFRN, 'author-link' => 'http://localhost/profile/othercontact', 'plink' => '', ] @@ -2635,7 +2645,7 @@ class ApiTest extends DatabaseTest $result = api_statusnet_config('json'); $this->assertEquals('localhost', $result['config']['site']['server']); $this->assertEquals('default', $result['config']['site']['theme']); - $this->assertEquals(\Friendica\Core\System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']); + $this->assertEquals(System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']); $this->assertTrue($result['config']['site']['fancy']); $this->assertEquals('en', $result['config']['site']['language']); $this->assertEquals('UTC', $result['config']['site']['timezone']); @@ -3377,7 +3387,7 @@ class ApiTest extends DatabaseTest */ public function testApiShareAsRetweet() { - $item = ['body' => '']; + $item = ['body' => '', 'author-id' => 1, 'owner-id' => 1]; $result = api_share_as_retweet($item); $this->assertFalse($result); }