Move integration tests to separate directory

Again, we do all of this to prepare for creating "real" test suites for
each type of tests.
This commit is contained in:
Franz Liedke
2019-01-01 22:17:09 +01:00
parent ba16ebe61f
commit 4d10536d35
26 changed files with 30 additions and 30 deletions

View File

@ -0,0 +1,86 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Tests\integration\api\Controller;
use Flarum\Api\Controller\ShowDiscussionController;
use Flarum\Discussion\Discussion;
use Flarum\Tests\integration\ManagesContent;
class ShowDiscussionControllerTest extends ApiControllerTestCase
{
use ManagesContent;
protected $controller = ShowDiscussionController::class;
/**
* @var Discussion
*/
protected $discussion;
protected function init()
{
$this->discussion = Discussion::start(__CLASS__, $this->getNormalUser());
}
/**
* @test
*/
public function author_can_see_discussion()
{
$this->discussion->save();
$this->actor = $this->getNormalUser();
$response = $this->callWith([], ['id' => $this->discussion->id]);
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function guest_cannot_see_empty_discussion()
{
$this->discussion->save();
$response = $this->callWith([], ['id' => $this->discussion->id]);
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
*/
public function guest_can_see_discussion()
{
$this->discussion->save();
$this->addPostByNormalUser();
$response = $this->callWith([], ['id' => $this->discussion->id]);
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function guests_cannot_see_private_discussion()
{
$this->discussion->is_private = true;
$this->discussion->save();
$this->callWith([], ['id' => $this->discussion->id]);
}
}