a normal reply - too-obscure
'],
+ ],
+ 'users' => [
+ $this->normalUser(),
+ ],
+ 'groups' => [
+ $this->guestGroup(),
+ $this->memberGroup(),
+ ],
+ 'group_user' => [
+ ['user_id' => 2, 'group_id' => 3],
+ ],
+ 'group_permission' => [
+ ['permission' => 'viewDiscussions', 'group_id' => 2],
+ ['permission' => 'viewDiscussions', 'group_id' => 3],
+ ]
+ ]);
}
/**
@@ -36,11 +60,9 @@ class ShowDiscussionControllerTest extends ApiControllerTestCase
*/
public function author_can_see_discussion()
{
- $this->discussion->save();
+ $this->actor = User::find(2);
- $this->actor = $this->getNormalUser();
-
- $response = $this->callWith([], ['id' => $this->discussion->id]);
+ $response = $this->callWith([], ['id' => 1]);
$this->assertEquals(200, $response->getStatusCode());
}
@@ -51,9 +73,7 @@ class ShowDiscussionControllerTest extends ApiControllerTestCase
*/
public function guest_cannot_see_empty_discussion()
{
- $this->discussion->save();
-
- $response = $this->callWith([], ['id' => $this->discussion->id]);
+ $response = $this->callWith([], ['id' => 1]);
$this->assertEquals(200, $response->getStatusCode());
}
@@ -63,11 +83,7 @@ class ShowDiscussionControllerTest extends ApiControllerTestCase
*/
public function guest_can_see_discussion()
{
- $this->discussion->save();
-
- $this->addPostByNormalUser();
-
- $response = $this->callWith([], ['id' => $this->discussion->id]);
+ $response = $this->callWith([], ['id' => 2]);
$this->assertEquals(200, $response->getStatusCode());
}
@@ -78,9 +94,6 @@ class ShowDiscussionControllerTest extends ApiControllerTestCase
*/
public function guests_cannot_see_private_discussion()
{
- $this->discussion->is_private = true;
- $this->discussion->save();
-
- $this->callWith([], ['id' => $this->discussion->id]);
+ $this->callWith([], ['id' => 3]);
}
}
diff --git a/framework/core/tests/integration/api/Controller/UpdateUserControllerTest.php b/framework/core/tests/integration/api/Controller/UpdateUserControllerTest.php
index a42562b62..bceb4895f 100644
--- a/framework/core/tests/integration/api/Controller/UpdateUserControllerTest.php
+++ b/framework/core/tests/integration/api/Controller/UpdateUserControllerTest.php
@@ -12,6 +12,7 @@
namespace Flarum\Tests\integration\api\Controller;
use Flarum\Api\Controller\UpdateUserController;
+use Flarum\User\User;
class UpdateUserControllerTest extends ApiControllerTestCase
{
@@ -21,24 +22,41 @@ class UpdateUserControllerTest extends ApiControllerTestCase
'email' => 'newemail@machine.local',
];
- protected $userAttributes = [
- 'username' => 'timtom',
- 'password' => 'too-obscure',
- 'email' => 'timtom@machine.local',
- 'is_email_confirmed' => true,
- ];
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->prepareDatabase([
+ 'users' => [
+ $this->adminUser(),
+ $this->normalUser(),
+ ],
+ 'groups' => [
+ $this->adminGroup(),
+ $this->memberGroup(),
+ ],
+ 'group_user' => [
+ ['user_id' => 1, 'group_id' => 1],
+ ['user_id' => 2, 'group_id' => 3],
+ ],
+ 'group_permission' => [
+ ['permission' => 'viewUserList', 'group_id' => 3],
+ ]
+ ]);
+ }
/**
* @test
*/
public function users_can_see_their_private_information()
{
- $this->actor = $this->getNormalUser();
- $response = $this->callWith([], ['id' => $this->actor->id]);
+ $this->actor = User::find(2);
+
+ $response = $this->callWith([], ['id' => 2]);
// Test for successful response and that the email is included in the response
$this->assertEquals(200, $response->getStatusCode());
- $this->assertContains('timtom@machine.local', (string) $response->getBody());
+ $this->assertContains('normal@machine.local', (string) $response->getBody());
}
/**
@@ -46,17 +64,12 @@ class UpdateUserControllerTest extends ApiControllerTestCase
*/
public function users_can_not_see_other_users_private_information()
{
- $this->actor = $this->getNormalUser();
+ $this->actor = User::find(2);
$response = $this->callWith([], ['id' => 1]);
// Make sure sensitive information is not made public
$this->assertEquals(200, $response->getStatusCode());
- $this->assertNotContains('admin@example.com', (string) $response->getBody());
- }
-
- public function tearDown()
- {
- parent::tearDown();
+ $this->assertNotContains('admin@machine.local', (string) $response->getBody());
}
}
diff --git a/framework/core/tests/integration/installer/DefaultInstallationTest.php b/framework/core/tests/integration/installer/DefaultInstallationTest.php
deleted file mode 100644
index 27eac7a42..000000000
--- a/framework/core/tests/integration/installer/DefaultInstallationTest.php
+++ /dev/null
@@ -1,75 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Flarum\Tests\Install;
-
-use Flarum\Install\AdminUser;
-use Flarum\Install\Installation;
-use Flarum\Tests\Test\TestCase;
-use Illuminate\Database\Connectors\ConnectionFactory;
-
-class DefaultInstallationTest extends TestCase
-{
- protected $isInstalled = false;
-
- /**
- * @test
- */
- public function allows_forum_installation()
- {
- if (file_exists(base_path('config.php'))) {
- unlink(base_path('config.php'));
- }
-
- /** @var Installation $installation */
- $installation = app(Installation::class);
-
- $installation
- ->debugMode(true)
- ->baseUrl('http://flarum.local')
- ->databaseConfig($this->getDatabaseConfiguration())
- ->adminUser($this->getAdmin())
- ->settings($this->getSettings())
- ->build()->run();
-
- $this->assertFileExists(base_path('config.php'));
-
- $this->assertEquals(
- $this->getDatabase()->table('users')->find(1)->username,
- 'admin'
- );
- }
-
- private function getDatabase()
- {
- $factory = new ConnectionFactory(app());
-
- return $factory->make($this->getDatabaseConfiguration()->toArray());
- }
-
- private function getAdmin(): AdminUser
- {
- return new AdminUser(
- 'admin',
- 'password',
- 'admin@example.com'
- );
- }
-
- private function getSettings()
- {
- return [
- 'forum_title' => 'Development Forum',
- 'mail_driver' => 'log',
- 'welcome_title' => 'Welcome to Development Forum',
- ];
- }
-}
diff --git a/framework/core/tests/phpunit.integration.xml b/framework/core/tests/phpunit.integration.xml
new file mode 100644
index 000000000..2ebc8b719
--- /dev/null
+++ b/framework/core/tests/phpunit.integration.xml
@@ -0,0 +1,23 @@
+
+
+