Enhanced testing

This commit is contained in:
buddha87 2016-06-05 19:12:12 +02:00
parent 8b77b7653d
commit c733cf17b6
75 changed files with 16407 additions and 287 deletions

View File

@ -0,0 +1,8 @@
actor: Tester
namespace: content
paths:
tests: codeception
log: codeception/_output
data: codeception/_data
helpers: codeception/_support

View File

@ -19,10 +19,10 @@
*/
return array(
['id' => 1, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839c', 'class' => 'humhub\modules\user\models\User', 'pk' => '1', 'owner_user_id' => 1, 'wall_id' => 1],
['id' => 2, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839d', 'class' => 'humhub\modules\user\models\User', 'pk' => '2', 'owner_user_id' => 2, 'wall_id' => 2],
['id' => 3, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839e', 'class' => 'humhub\modules\user\models\User', 'pk' => '3', 'owner_user_id' => 3, 'wall_id' => 3],
['id' => 4, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34a', 'class' => 'humhub\modules\space\models\Space', 'pk' => '1', 'owner_user_id' => 1, 'wall_id' => 4],
['id' => 5, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34b', 'class' => 'humhub\modules\space\models\Space', 'pk' => '2', 'owner_user_id' => 2, 'wall_id' => 5],
['id' => 6, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34c', 'class' => 'humhub\modules\space\models\Space', 'pk' => '3', 'owner_user_id' => 3, 'wall_id' => 6],
['id' => 1, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839c', 'class' => 'humhub\modules\user\models\User', 'pk' => '1', 'owner_user_id' => 1],
['id' => 2, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839d', 'class' => 'humhub\modules\user\models\User', 'pk' => '2', 'owner_user_id' => 2],
['id' => 3, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839e', 'class' => 'humhub\modules\user\models\User', 'pk' => '3', 'owner_user_id' => 3],
['id' => 4, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34a', 'class' => 'humhub\modules\space\models\Space', 'pk' => '1', 'owner_user_id' => 1],
['id' => 5, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34b', 'class' => 'humhub\modules\space\models\Space', 'pk' => '2', 'owner_user_id' => 2],
['id' => 6, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34c', 'class' => 'humhub\modules\space\models\Space', 'pk' => '3', 'owner_user_id' => 3],
);

View File

@ -0,0 +1,26 @@
<?php
namespace content;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use content\_generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,26 @@
<?php
namespace content;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,26 @@
<?php
namespace content;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,18 @@
<?php //[STAMP] 4493afa159a655f6c31f96576ab8ecaf
namespace content\_generated;
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
use tests\codeception\_support\CodeHelper;
trait UnitTesterActions
{
/**
* @return \Codeception\Scenario
*/
abstract protected function getScenario();
}

View File

@ -0,0 +1,28 @@
# Codeception Test Suite Configuration
# suite for acceptance tests.
# perform tests in browser using the Selenium-like tools.
# powered by Mink (http://mink.behat.org).
# (tip: that's what your customer will see).
# (tip: test your ajax and javascript by one of Mink drivers).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser
- tests\codeception\_support\WebHelper
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
# it is useful if you want to login in your app in each test.
# - WebDriver
config:
PhpBrowser:
# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
url: http://localhost:8080
# WebDriver:
# url: http://localhost:8080
# browser: firefox
# restart: true

View File

@ -0,0 +1,17 @@
# Codeception Test Suite Configuration
# suite for functional (integration) tests.
# emulate web requests and make application process them.
# (tip: better to use with frameworks).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: FunctionalTester
modules:
enabled:
- Filesystem
- Yii2
- tests\codeception\_support\FixtureHelper
- tests\codeception\_support\TestHelper
config:
Yii2:
configFile: '../../../tests/codeception/config/functional.php'

View File

@ -0,0 +1,9 @@
# Codeception Test Suite Configuration
# suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: UnitTester
modules:
enabled:
- tests\codeception\_support\CodeHelper

View File

@ -0,0 +1,28 @@
<?php //[STAMP] 52132e1f0b55255ff48c969c21446b84
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
namespace user;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
}

View File

@ -10,10 +10,10 @@ use tests\codeception\fixtures\ContentContainerFixture;
use tests\codeception\fixtures\SpaceFixture;
use tests\codeception\fixtures\SpaceMembershipFixture;
use humhub\modules\post\models\Post;
use humhub\modules\content\components\actions\ContentContainerStream;
use humhub\modules\user\models\User;
use humhub\modules\space\models\Space;
use humhub\modules\content\models\Content;
use humhub\modules\stream\actions\ContentContainerStream;
class ContentContainerStreamTest extends DbTestCase
{
@ -43,14 +43,14 @@ class ContentContainerStreamTest extends DbTestCase
$post1->content->setContainer($space);
$post1->content->visibility = Content::VISIBILITY_PRIVATE;
$post1->save();
$w1 = $post1->content->getFirstWallEntryId();
$w1 = $post1->content->id;
$post2 = new Post;
$post2->message = "Public Post";
$post2->content->setContainer($space);
$post2->content->visibility = Content::VISIBILITY_PUBLIC;
$post2->save();
$w2 = $post2->content->getFirstWallEntryId();
$w2 = $post2->content->id;
$ids = $this->getStreamActionIds($space, 2);
@ -68,14 +68,14 @@ class ContentContainerStreamTest extends DbTestCase
$post1->content->setContainer($space);
$post1->content->visibility = Content::VISIBILITY_PRIVATE;
$post1->save();
$w1 = $post1->content->getFirstWallEntryId();
$w1 = $post1->content->id;
$post2 = new Post;
$post2->message = "Public Post";
$post2->content->setContainer($space);
$post2->content->visibility = Content::VISIBILITY_PUBLIC;
$post2->save();
$w2 = $post2->content->getFirstWallEntryId();
$w2 = $post2->content->id;
$this->becomeUser('Admin');
@ -96,7 +96,7 @@ class ContentContainerStreamTest extends DbTestCase
$action->contentContainer = $container;
$action->limit = $limit;
$wallEntries = $action->getWallEntries();
$wallEntries = $action->activeQuery->all();
$wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries);
return $wallEntryIds;

View File

@ -9,14 +9,12 @@ use tests\codeception\fixtures\UserFixture;
use tests\codeception\fixtures\GroupFixture;
use tests\codeception\fixtures\SpaceFixture;
use tests\codeception\fixtures\SpaceMembershipFixture;
use tests\codeception\fixtures\WallFixture;
use tests\codeception\fixtures\WallEntryFixture;
use tests\codeception\fixtures\ContentFixture;
use tests\codeception\fixtures\PostFixture;
use humhub\modules\post\models\Post;
use humhub\modules\content\components\actions\Stream;
use humhub\modules\user\models\User;
use humhub\modules\activity\models\Activity;
use humhub\modules\stream\actions\Stream;
class StreamActionTest extends DbTestCase
{
@ -41,18 +39,11 @@ class StreamActionTest extends DbTestCase
'space_membership' => [
'class' => SpaceMembershipFixture::className(),
],
'wall' => [
'class' => WallFixture::className(),
],
'wall_entry' => [
'class' => WallEntryFixture::className(),
],
'content' => [
'class' => ContentFixture::className(),
],
'post' => [
'class' => PostFixture::className(),
],
];
}
@ -71,25 +62,25 @@ class StreamActionTest extends DbTestCase
$post->message = "P1";
$post->content->container = Yii::$app->user->getIdentity();
$post->save();
$this->postWallEntryIds[] = $post->content->getFirstWallEntryId();
$this->postWallEntryIds[] = $post->content->id;
$post = new Post;
$post->message = "P2";
$post->content->container = Yii::$app->user->getIdentity();
$post->save();
$this->postWallEntryIds[] = $post->content->getFirstWallEntryId();
$this->postWallEntryIds[] = $post->content->id;
$post = new Post;
$post->message = "P3";
$post->content->container = Yii::$app->user->getIdentity();
$post->save();
$this->postWallEntryIds[] = $post->content->getFirstWallEntryId();
$this->postWallEntryIds[] = $post->content->id;
$post = new Post;
$post->message = "P4";
$post->content->container = Yii::$app->user->getIdentity();
$post->save();
$this->postWallEntryIds[] = $post->content->getFirstWallEntryId();
$this->postWallEntryIds[] = $post->content->id;
$this->postWallEntryIds = array_reverse($this->postWallEntryIds);
}
@ -97,10 +88,10 @@ class StreamActionTest extends DbTestCase
public function testModeNormal()
{
Yii::$app->user->switchIdentity(User::findOne(['id' => 1]));
$streamAction = new Stream('stream', Yii::$app->controller);
//$streamAction = new Stream('stream', Yii::$app->controller);
$streamAction->init();
$wallEntries = $streamAction->getWallEntries();
$wallEntries = $streamAction->activeQuery->all();
$wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries);
$this->assertEquals($this->postWallEntryIds, $wallEntryIds);
@ -116,11 +107,11 @@ class StreamActionTest extends DbTestCase
$post->content->setContainer(Yii::$app->user->getIdentity());
$post->save();
$streamAction = new Stream('stream', Yii::$app->controller);
//$streamAction = new Stream('stream', Yii::$app->controller);
$streamAction->mode = Stream::MODE_ACTIVITY;
$streamAction->init();
$wallEntries = $streamAction->getWallEntries();
$wallEntries = $streamAction->activeQuery->all();
assert(count($wallEntries) == 4);
@ -143,11 +134,11 @@ class StreamActionTest extends DbTestCase
$user->status = User::STATUS_DISABLED;
$user->save();
$baseStreamAction = new Stream('stream', Yii::$app->controller);
//$baseStreamAction = new Stream('stream', Yii::$app->controller);
$baseStreamAction->mode = Stream::MODE_NORMAL;
$baseStreamAction->init();
$wallEntries = $baseStreamAction->getWallEntries();
$wallEntries = $baseStreamAction->activeQuery->all();
$wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries);
$this->assertEquals($this->postWallEntryIds, $wallEntryIds);
}
@ -163,31 +154,31 @@ class StreamActionTest extends DbTestCase
$post1->message = "P1";
$post1->content->setContainer(Yii::$app->user->getIdentity());
$post1->save();
$post1wallEntryId = $post1->content->getFirstWallEntryId();
$post1wallEntryId = $post1->content->id;
sleep(1);
$post2 = new Post;
$post2->message = "P2";
$post2->content->setContainer(Yii::$app->user->getIdentity());
$post2->save();
$post2wallEntryId = $post2->content->getFirstWallEntryId();
$post2wallEntryId = $post2->content->id;
sleep(1);
$post1->message = "P1b";
$post1->save();
$baseStreamAction = new Stream('stream', Yii::$app->controller);
//$baseStreamAction = new Stream('stream', Yii::$app->controller);
$baseStreamAction->limit = 2;
$baseStreamAction->init();
$wallEntries = $baseStreamAction->getWallEntries();
$wallEntries = $baseStreamAction->activeQuery->all();
$wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries);
$this->assertEquals(array($post2wallEntryId, $post1wallEntryId), $wallEntryIds);
$baseStreamAction = new Stream('stream', Yii::$app->controller);
//$baseStreamAction = new Stream('stream', Yii::$app->controller);
$baseStreamAction->limit = 2;
$baseStreamAction->sort = Stream::SORT_UPDATED_AT;
$baseStreamAction->init();
$wallEntries = $baseStreamAction->getWallEntries();
$wallEntries = $baseStreamAction->activeQuery->all();
$wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries);
$this->assertEquals(array($post1wallEntryId, $post2wallEntryId), $wallEntryIds);
@ -200,11 +191,11 @@ class StreamActionTest extends DbTestCase
public function testLimit()
{
$baseStreamAction = new Stream('stream', Yii::$app->controller);
//$baseStreamAction = new Stream('stream', Yii::$app->controller);
$baseStreamAction->limit = 2;
$baseStreamAction->init();
$wallEntries = $baseStreamAction->getWallEntries();
$wallEntries = $baseStreamAction->activeQuery->all();
$wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries);
$this->assertEquals(array_slice($this->postWallEntryIds, 0, 2), $wallEntryIds);
}

View File

@ -0,0 +1,17 @@
actor: Tester
namespace: user
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
memory_limit: 1024M
log: true
paths:
tests: codeception
log: codeception/_output
data: codeception/_data
helpers: codeception/_support
config:
# the entry script URL (with host info) for functional and acceptance tests
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
test_entry_url: http://localhost:8080/index-test.php

View File

@ -0,0 +1,22 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
defined('YII_TEST_ENTRY_FILE') or define('YII_TEST_ENTRY_FILE', dirname(dirname(dirname(dirname(__DIR__)))) . '/index-test.php');
require_once(__DIR__ . '/../../../../../vendor/autoload.php');
require_once(__DIR__ . '/../../../../../vendor/yiisoft/yii2/Yii.php');
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST);
$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ? : '80';
Yii::setAlias('@tests', dirname(__DIR__));
Yii::setAlias('@modules', realpath(dirname(dirname(__DIR__)).'../../'));
\Codeception\Util\Autoload::addNamespace('', __DIR__. '/../../../../tests/codeception/_support');
\Codeception\Util\Autoload::addNamespace('tests\codeception\fixtures', __DIR__. '/../../../../tests/codeception/fixtures');
\Codeception\Util\Autoload::addNamespace('', __DIR__. '/../../../../tests/codeception/_pages');

View File

@ -0,0 +1,25 @@
<?php
/**
* HumHub
* Copyright © 2014 The HumHub Project
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*/
return array(
// Working Users
array('id' => 1, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839c', 'status' => '1','username' => 'Admin', 'email' => 'user1@example.com', 'auth_mode' => 'local', 'tags' => NULL, 'language' => '', 'last_activity_email' => '2014-08-08 05:36:02', 'created_at' => '2014-08-08 05:36:02', 'created_by' => NULL, 'updated_at' => '2014-08-08 05:36:19', 'updated_by' => '1', 'last_login' => '2014-08-05 05:36:16'),
array('id' => 2, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839d', 'status' => '1','username' => 'User2', 'email' => 'user2@example.com', 'auth_mode' => 'local', 'tags' => NULL, 'language' => '', 'last_activity_email' => '2014-08-08 05:36:02', 'created_at' => '2014-08-08 05:36:02', 'created_by' => NULL, 'updated_at' => '2014-08-08 05:36:19', 'updated_by' => '1', 'last_login' => '2014-08-06 05:36:16'),
array('id' => 3, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839e', 'status' => '1','username' => 'User3', 'email' => 'user3@example.com', 'auth_mode' => 'local', 'tags' => NULL, 'language' => '', 'last_activity_email' => '2014-08-08 05:36:02', 'created_at' => '2014-08-08 05:36:02', 'created_by' => NULL, 'updated_at' => '2014-08-08 05:36:19', 'updated_by' => '1', 'last_login' => '2014-08-07 05:36:16'),
);

View File

@ -0,0 +1,26 @@
<?php
namespace user;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,26 @@
<?php
namespace user;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,26 @@
<?php
namespace user;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,18 @@
<?php //[STAMP] 4493afa159a655f6c31f96576ab8ecaf
namespace user\_generated;
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
use tests\codeception\_support\CodeHelper;
trait UnitTesterActions
{
/**
* @return \Codeception\Scenario
*/
abstract protected function getScenario();
}

View File

@ -0,0 +1,31 @@
# Codeception Test Suite Configuration
# suite for acceptance tests.
# perform tests in browser using the Selenium-like tools.
# powered by Mink (http://mink.behat.org).
# (tip: that's what your customer will see).
# (tip: test your ajax and javascript by one of Mink drivers).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- tests\codeception\_support\WebHelper
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
# it is useful if you want to login in your app in each test.
# - WebDriver
config:
WebDriver:
url: http://localhost:8080
browser: phantomjs
restart: true
# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
#url: http://localhost:8080
# WebDriver:
# url: http://localhost:8080
# browser: firefox
# restart: true

View File

@ -0,0 +1,92 @@
<?php
namespace user\acceptance;
use tests\codeception\_pages\LoginPage;
use FunctionalTester;
class LoginCest
{
public function testUserLogin(FunctionalTester $I)
{
$I->wantTo('ensure that login works');
$I->amOnPage('/user/auth/login');
$I->expectTo('see login page');
$I->see('Login');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('try to login with empty credentials');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.');
$I->see('Password cannot be blank.');
$I->amGoingTo('try to login with wrong credentials');
$loginPage->login('User2', 'wrong');
$I->expectTo('see validations errors');
$I->see('User or Password incorrect.');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('User2', '123qwe');
$I->expectTo('see dashboard');
$I->see('Dashboard');
$I->dontSee('Administration');
}
public function testAdminLogin(FunctionalTester $I)
{
$I->wantTo('ensure that login as admin works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('try to login with admin credentials');
$loginPage->login('admin', 'test');
$I->expectTo('see dashboard');
$I->see('Dashboard');
$I->see('Administration');
}
public function testLoginByEMail(FunctionalTester $I)
{
$I->wantTo('ensure that login with email works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('try to login with admin credentials');
$loginPage->login('user1@example.com', 'test');
$I->expectTo('see dashboard');
$I->see('Dashboard');
$I->see('Administration');
}
public function testLogout(FunctionalTester $I)
{
$I->wantTo('ensure that logout works');
$loginPage = LoginPage::openBy($I);
$loginPage->login('admin', 'test');
$I->expectTo('see logout link');
$I->seeLink('Logout');
$I->click('Logout');
$I->expectTo('see login screen');
$I->seeInCurrentUrl('login');
}
public function testDisabledUser(FunctionalTester $I)
{
$I->wantTo('ensure that disabled user cannot login');
$loginPage = LoginPage::openBy($I);
$loginPage->login('DisabledUser', '123qwe');
$I->expectTo('see validations errors');
$I->see('Your account is disabled!');
}
public function testUnApprovedUser(FunctionalTester $I)
{
$I->wantTo('ensure that unapproved user cannot login');
$loginPage = LoginPage::openBy($I);
$loginPage->login('UnApprovedUser', '123qwe');
$I->expectTo('see validations errors');
$I->see('Your account is not approved yet!');
}
//Login by email
}

View File

@ -0,0 +1,3 @@
<?php
$config = require(dirname(__DIR__) . '/../../../../tests/codeception/config/acceptance.php');
new humhub\components\Application($config);

View File

@ -0,0 +1,17 @@
# Codeception Test Suite Configuration
# suite for functional (integration) tests.
# emulate web requests and make application process them.
# (tip: better to use with frameworks).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: FunctionalTester
modules:
enabled:
- Filesystem
- Yii2
- tests\codeception\_support\TestHelper
- tests\codeception\_support\FixtureHelper
config:
Yii2:
configFile: '../../../tests/codeception/config/functional.php'

View File

@ -0,0 +1,90 @@
<?php
namespace user\functional;
use tests\codeception\_pages\LoginPage;
use FunctionalTester;
class LoginCest
{
public function testUserLogin(FunctionalTester $I)
{
//require('/codebase/humhub/v1.2-dev/protected/humhub/tests/codeception/_pages/LoginPage.php');
//\Codeception\Util\Autoload::addNamespace('tests', '/codebase/humhub/v1.2-dev/protected/humhub/tests');
$I->wantTo('ensure that login works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('try to login with empty credentials');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.');
$I->see('Password cannot be blank.');
$I->amGoingTo('try to login with wrong credentials');
$loginPage->login('User2', 'wrong');
$I->expectTo('see validations errors');
$I->see('User or Password incorrect.');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('User2', '123qwe');
$I->expectTo('see dashboard');
$I->see('Dashboard');
$I->dontSee('Administration');
}
public function testAdminLogin(FunctionalTester $I)
{
$I->wantTo('ensure that login as admin works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('try to login with admin credentials');
$loginPage->login('admin', 'test');
$I->expectTo('see dashboard');
$I->see('Dashboard');
$I->see('Administration');
}
public function testLoginByEMail(FunctionalTester $I)
{
$I->wantTo('ensure that login with email works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('try to login with admin credentials');
$loginPage->login('user1@example.com', 'test');
$I->expectTo('see dashboard');
$I->see('Dashboard');
$I->see('Administration');
}
public function testLogout(FunctionalTester $I)
{
$I->wantTo('ensure that logout works');
$loginPage = LoginPage::openBy($I);
$loginPage->login('admin', 'test');
$I->expectTo('see logout link');
$I->seeLink('Logout');
$I->click('Logout');
$I->expectTo('see login screen');
$I->seeInCurrentUrl('login');
}
public function testDisabledUser(FunctionalTester $I)
{
$I->wantTo('ensure that disabled user cannot login');
$loginPage = LoginPage::openBy($I);
$loginPage->login('DisabledUser', '123qwe');
$I->expectTo('see validations errors');
$I->see('Your account is disabled!');
}
public function testUnApprovedUser(FunctionalTester $I)
{
$I->wantTo('ensure that unapproved user cannot login');
$loginPage = LoginPage::openBy($I);
$loginPage->login('UnApprovedUser', '123qwe');
$I->expectTo('see validations errors');
$I->see('Your account is not approved yet!');
}
//Login by email
}

View File

@ -0,0 +1,3 @@
<?php
$config = require(dirname(__DIR__) . '/../../../../tests/codeception/config/functional.php');
new humhub\components\Application($config);

View File

@ -0,0 +1,9 @@
# Codeception Test Suite Configuration
# suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: UnitTester
modules:
enabled:
- tests\codeception\_support\CodeHelper

View File

@ -0,0 +1,28 @@
<?php //[STAMP] 52132e1f0b55255ff48c969c21446b84
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
namespace user;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
}

View File

@ -13,7 +13,7 @@ use tests\codeception\fixtures\InviteFixture;
use humhub\modules\user\models\User;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\Invite;
use humhub\modules\content\models\Wall;
use humhub\modules\content\models\ContentContainer;
use humhub\modules\user\models\Group;
class UserTest extends DbTestCase
@ -109,17 +109,16 @@ class UserTest extends DbTestCase
$this->assertTrue($space3->isMember($user->id)); // via global assign
}
public function testAutoWallCreation()
public function testAutoContentContainerCreation()
{
$user = new User();
$user->username = "wallTest";
$user->email = "wall@example.com";
$user->username = "userStreamTest";
$user->email = "userStreamTest@example.com";
$this->assertTrue($user->save());
$this->assertNotNull($user->wall_id);
$wall = Wall::findOne(['id' => $user->wall_id]);
$this->assertNotNull($wall);
$this->assertNotNull($user->contentcontainer_id);
$contentContainer = ContentContainer::findOne(['id' => $user->contentcontainer_id]);
$this->assertNotNull($contentContainer);
}
}

View File

@ -24,6 +24,11 @@ paths:
log: codeception/_output
data: codeception/_data
helpers: codeception/_support
extensions:
enabled:
- tests\codeception\_support\HumHubModuleExtension
include:
- ../modules/*/tests
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite

View File

@ -16,3 +16,4 @@ $_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config
$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ? : '80';
Yii::setAlias('@tests', dirname(__DIR__));
Yii::setAlias('@modules', dirname(dirname(__DIR__)).'/modules');

View File

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,26 @@
<?php
namespace tests\codeception\_support;
use Codeception\Module;
/**
* This helper is used to populate the database with needed fixtures before any tests are run.
* In this example, the database is populated with the demo login user, which is used in acceptance
* and functional tests. All fixtures will be loaded before the suite is started and unloaded after it
* completes.
*/
class CodeHelper extends Module
{
/**
* Method called before any suite tests run. Loads User fixture login user
* to use in acceptance and functional tests.
* @param array $settings
*/
public function _beforeSuite($settings = [])
{
include __DIR__.'/../unit/_bootstrap.php';
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace tests\codeception\_support;
use tests\codeception\fixtures\UserFixture;
use Codeception\Module;
use yii\test\FixtureTrait;
use yii\test\InitDbFixture;
/**
* This helper is used to populate the database with needed fixtures before any tests are run.
* In this example, the database is populated with the demo login user, which is used in acceptance
* and functional tests. All fixtures will be loaded before the suite is started and unloaded after it
* completes.
*/
class FixtureHelper extends Module
{
/**
* Redeclare visibility because codeception includes all public methods that do not start with "_"
* and are not excluded by module settings, in actor class.
*/
use FixtureTrait {
loadFixtures as public;
fixtures as public;
globalFixtures as public;
createFixtures as public;
unloadFixtures as protected;
getFixtures as protected;
getFixture as protected;
}
/**
* Method called before any suite tests run. Loads User fixture login user
* to use in acceptance and functional tests.
* @param array $settings
*/
public function _beforeSuite($settings = [])
{
//Prevents [ReflectionException] Class db does not exist for included module tests
include __DIR__.'/../functional/_bootstrap.php';
$this->loadFixtures();
}
/**
* Method is called after all suite tests run
*/
public function _afterSuite()
{
$this->unloadFixtures();
}
/**
* @inheritdoc
*/
public function globalFixtures()
{
return [
InitDbFixture::className(),
];
}
/**
* @inheritdoc
*/
public function fixtures()
{
return [
'user' => [
'class' => \tests\codeception\fixtures\UserFixture::className()
],
'password' => [
'class' => \tests\codeception\fixtures\UserPasswordFixture::className()
]
];
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,21 @@
<?php
namespace tests\codeception\_support;
use Codeception\Events;
class HumHubModuleExtension extends \Codeception\Extension
{
// list events to listen to
public static $events = array(
Events::MODULE_INIT => 'beforeSuite',
);
// methods that handle events
public function beforeSuite(\Codeception\Event\SuiteEvent $e) {
$settings = $e->getSettings();
#$settings['modules']['config']['WebDriver']['url'] = '';
#$e->getSuite()->getModules()['WebDriver']->_reconfigure(['url' => 'http://localhost/codebase/humhub/v1.1-dev/index.phpxxx']);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace tests\codeception\_support;
use Codeception\Module;
/**
* This helper is used to populate the database with needed fixtures before any tests are run.
* In this example, the database is populated with the demo login user, which is used in acceptance
* and functional tests. All fixtures will be loaded before the suite is started and unloaded after it
* completes.
*/
class TestHelper extends Module
{
/**
* Method called before any suite tests run. Loads User fixture login user
* to use in acceptance and functional tests.
* @param array $settings
*/
public function _beforeSuite($settings = [])
{
include __DIR__.'/../functional/_bootstrap.php';
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,30 @@
<?php
namespace tests\codeception\_support;
use Codeception\Module;
/**
* This helper is used to populate the database with needed fixtures before any tests are run.
* In this example, the database is populated with the demo login user, which is used in acceptance
* and functional tests. All fixtures will be loaded before the suite is started and unloaded after it
* completes.
*/
class WebHelper extends Module
{
/**
* Method called before any suite tests run. Loads User fixture login user
* to use in acceptance and functional tests.
* @param array $settings
*/
public function _beforeSuite($settings = [])
{
include __DIR__.'/../acceptance/_bootstrap.php';
}
public function _before(\Codeception\TestCase $test) {
//$this->getModule('WebDriver')->_reconfigure(array('url' => 'http://staff.humhub.org'));
}
}

View File

@ -0,0 +1,18 @@
<?php //[STAMP] ea40a453a487fa3632a18d4dadac1a58
namespace _generated;
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
trait UnitTesterActions
{
/**
* @return \Codeception\Scenario
*/
abstract protected function getScenario();
}

View File

@ -11,17 +11,20 @@
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser
- WebDriver
- tests\codeception\_support\WebHelper
#- PhpBrowser
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
# it is useful if you want to login in your app in each test.
# - WebDriver
config:
PhpBrowser:
WebDriver:
url: http://localhost/codebase/humhub/v1.1-dev/index.php
browser: phantomjs
restart: true
#PhpBrowser:
# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
url: http://localhost:8080
# WebDriver:
# url: http://localhost:8080
# browser: firefox
# restart: true
# url: http://localhost:8080

View File

@ -1,39 +0,0 @@
<?php
use tests\codeception\_pages\LoginPage;
/* @var $scenario Codeception\Scenario */
$I = new AcceptanceTester($scenario);
$I->wantTo('ensure that login works');
$loginPage = LoginPage::openBy($I);
$I->see('sign in');
$I->amGoingTo('try to login with empty credentials');
$loginPage->login('', '');
if (method_exists($I, 'wait')) {
$I->wait(3); // only for selenium
}
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.');
$I->see('Password cannot be blank.');
$I->amGoingTo('try to login with wrong credentials');
$loginPage->login('admin', 'wrong');
if (method_exists($I, 'wait')) {
$I->wait(3); // only for selenium
}
$I->expectTo('see validations errors');
$I->see('User or Password incorrect.');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('admin', 'test');
if (method_exists($I, 'wait')) {
$I->wait(3); // only for selenium
}
$I->expectTo('see dashboard');
$I->see('Dashboard');

View File

@ -25,7 +25,6 @@ $config = yii\helpers\ArrayHelper::merge(
$consoleConfig
);
$application = new humhub\components\console\Application($config);
$application->params['installed'] = false;

View File

@ -20,8 +20,8 @@ return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=humhub_test',
'username' => 'travis',
'password' => '',
'username' => 'root',
'password' => '12manyhacks',
'charset' => 'utf8',
],
'mailer' => [

View File

@ -12,8 +12,6 @@ use yii\test\ActiveFixture;
class ContentContainerFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\content\models\ContentContainer';
public $dataFile = '@tests/codeception/fixtures/data/contentcontainer.php';
public $dataFile = '@modules/content/tests/codeception/_data/contentcontainer.php';
}

View File

@ -14,7 +14,7 @@ class ContentFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\content\models\Content';
public $dataFile = '@tests/codeception/fixtures/data/content.php';
public $dataFile = '@tests/../modules/content/tests/codeception/_data/content.php';
public $depends = [
'tests\codeception\fixtures\ContentContainerFixture'

View File

@ -14,7 +14,7 @@ class GroupFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\user\models\Group';
public $dataFile = '@tests/codeception/fixtures/data/group.php';
public $dataFile = '@modules/user/tests/codeception/_data/group.php';
public $depends = [
'tests\codeception\fixtures\GroupUserFixture'

View File

@ -14,6 +14,6 @@ class GroupUserFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\user\models\GroupUser';
public $dataFile = '@tests/codeception/fixtures/data/groupuser.php';
public $dataFile = '@modules/user/tests/codeception/_data/groupuser.php';
}

View File

@ -14,7 +14,6 @@ class InviteFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\user\models\Invite';
public $dataFile = '@tests/codeception/fixtures/data/user_invite.php';
public $dataFile = '@modules/user/tests/codeception/_data/user_invite.php';
}

View File

@ -14,7 +14,7 @@ class UserFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\user\models\User';
public $dataFile = '@tests/codeception/fixtures/data/user.php';
public $dataFile = '@modules/user/tests/codeception/_data/user.php';
public $depends = [
'tests\codeception\fixtures\ContentContainerFixture'
];

View File

@ -14,6 +14,6 @@ class UserFollowFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\user\models\Follow';
public $dataFile = '@tests/codeception/fixtures/data/user_follow.php';
public $dataFile = '@modules/user/tests/codeception/_data/user_follow.php';
}

View File

@ -0,0 +1,22 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace tests\codeception\fixtures;
use yii\test\ActiveFixture;
class UserPasswordFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\user\models\Password';
public $dataFile = '@modules/user/tests/codeception/_data/user_password.php';
public $depends = [
'tests\codeception\fixtures\UserFixture'
];
}

View File

@ -0,0 +1,22 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace tests\codeception\fixtures;
use yii\test\ActiveFixture;
class UserFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\user\models\Profile';
public $dataFile = '@modules/user/tests/codeception/_data/profile.php';
public $depends = [
'tests\codeception\fixtures\UserProfileFixture'
];
}

View File

@ -1,18 +0,0 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace tests\codeception\fixtures;
use yii\test\ActiveFixture;
class WallEntryFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\content\models\WallEntry';
public $dataFile = '@tests/codeception/fixtures/data/wall_entry.php';
}

View File

@ -1,19 +0,0 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace tests\codeception\fixtures;
use yii\test\ActiveFixture;
class WallFixture extends ActiveFixture
{
public $modelClass = 'humhub\modules\content\models\Wall';
public $dataFile = '@tests/codeception/fixtures/data/wall.php';
}

View File

@ -18,8 +18,8 @@
* GNU Affero General Public License for more details.
*/
return array(
array('id' => '1', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34a', 'wall_id' => '4', 'name' => 'Space 1', 'description' => 'Space by Admin', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '1', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'),
array('id' => '2', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34b', 'wall_id' => '5', 'name' => 'Space 2', 'description' => 'User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'),
array('id' => '3', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34c', 'wall_id' => '6', 'name' => 'Space 3', 'description' => 'Another User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '1')
array('id' => '1', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34a', 'name' => 'Space 1', 'description' => 'Space by Admin', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '1', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'),
array('id' => '2', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34b', 'name' => 'Space 2', 'description' => 'User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'),
array('id' => '3', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34c', 'name' => 'Space 3', 'description' => 'Another User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '1')
);

View File

@ -1,25 +0,0 @@
<?php
/**
* HumHub
* Copyright © 2014 The HumHub Project
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*/
return array(
// Working Users
array('id' => 1, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839c', 'wall_id' => '2', 'status' => '1','username' => 'Admin', 'email' => 'user1@example.com', 'auth_mode' => 'local', 'tags' => NULL, 'language' => '', 'last_activity_email' => '2014-08-08 05:36:02', 'created_at' => '2014-08-08 05:36:02', 'created_by' => NULL, 'updated_at' => '2014-08-08 05:36:19', 'updated_by' => '1', 'last_login' => '2014-08-05 05:36:16'),
array('id' => 2, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839d', 'wall_id' => '3', 'status' => '1','username' => 'User2', 'email' => 'user2@example.com', 'auth_mode' => 'local', 'tags' => NULL, 'language' => '', 'last_activity_email' => '2014-08-08 05:36:02', 'created_at' => '2014-08-08 05:36:02', 'created_by' => NULL, 'updated_at' => '2014-08-08 05:36:19', 'updated_by' => '1', 'last_login' => '2014-08-06 05:36:16'),
array('id' => 3, 'guid' => '01e50e0d-82cd-41fc-8b0c-552392f5839e', 'wall_id' => '4', 'status' => '1','username' => 'User3', 'email' => 'user3@example.com', 'auth_mode' => 'local', 'tags' => NULL, 'language' => '', 'last_activity_email' => '2014-08-08 05:36:02', 'created_at' => '2014-08-08 05:36:02', 'created_by' => NULL, 'updated_at' => '2014-08-08 05:36:19', 'updated_by' => '1', 'last_login' => '2014-08-07 05:36:16'),
);

View File

@ -1,27 +0,0 @@
<?php
/**
* HumHub
* Copyright © 2014 The HumHub Project
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*/
return array(
array('id' => '1', 'object_model' => 'humhub\modules\user\models\User', 'object_id' => '1', 'created_at' => '2014-08-08 05:36:19', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:19', 'updated_by' => '1'),
array('id' => '2', 'object_model' => 'humhub\modules\user\models\User', 'object_id' => '2', 'created_at' => '2014-08-10 16:55:43', 'created_by' => '2', 'updated_at' => '2014-08-10 16:55:43', 'updated_by' => '2'),
array('id' => '3', 'object_model' => 'humhub\modules\user\models\User', 'object_id' => '3', 'created_at' => '2014-08-10 16:55:43', 'created_by' => '2', 'updated_at' => '2014-08-10 16:55:43', 'updated_by' => '2'),
array('id' => '4', 'object_model' => 'humhub\modules\space\models\Space', 'object_id' => '1', 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '1'),
array('id' => '5', 'object_model' => 'humhub\modules\space\models\Space', 'object_id' => '2', 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '1'),
array('id' => '6', 'object_model' => 'humhub\modules\space\models\Space', 'object_id' => '3', 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '1'),
);

View File

@ -1,34 +0,0 @@
<?php
/**
* HumHub
* Copyright © 2014 The HumHub Project
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*/
return array(
array('id' => '1', 'wall_id' => '1', 'content_id' => '1', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '2', 'wall_id' => '1', 'content_id' => '2', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '3', 'wall_id' => '2', 'content_id' => '3', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '4', 'wall_id' => '2', 'content_id' => '4', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '5', 'wall_id' => '3', 'content_id' => '5', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '6', 'wall_id' => '3', 'content_id' => '6', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '7', 'wall_id' => '4', 'content_id' => '7', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '8', 'wall_id' => '4', 'content_id' => '8', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '9', 'wall_id' => '4', 'content_id' => '9', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '10', 'wall_id' => '5', 'content_id' => '10', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '2'),
array('id' => '11', 'wall_id' => '5', 'content_id' => '11', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '2'),
);

View File

@ -1,26 +0,0 @@
<?php
use tests\codeception\_pages\LoginPage;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that login works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('try to login with empty credentials');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.');
$I->see('Password cannot be blank.');
$I->amGoingTo('try to login with wrong credentials');
$loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors');
$I->see('User or Password incorrect.');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('admin', 'test');
$I->expectTo('see dashboard');
$I->see('Dashboard');

View File

@ -0,0 +1,36 @@
<?php
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
/**
* Application configuration for functional tests
*/
$testConfig = [
'components' => [
'request' => [
// it's not recommended to run functional tests with CSRF validation enabled
'enableCsrfValidation' => false,
'cookieValidationKey' => 'test'
// but if you absolutely need it set cookie domain to localhost
/*
'csrfCookie' => [
'domain' => 'localhost',
],
*/
],
],
];
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(dirname(__DIR__)))));
return yii\helpers\ArrayHelper::merge(
// Common Config
require(YII_APP_BASE_PATH . '/humhub/config/common.php'),
// Web Config
require(YII_APP_BASE_PATH . '/humhub/config/web.php'),
// Test Common Config
require(dirname(__DIR__) . '/config/config.php'),
// Functional Test Config
$testConfig
);

View File

@ -9,8 +9,6 @@ use tests\codeception\fixtures\UserFixture;
use tests\codeception\fixtures\GroupFixture;
use tests\codeception\fixtures\SpaceFixture;
use tests\codeception\fixtures\SpaceMembershipFixture;
use tests\codeception\fixtures\WallFixture;
use tests\codeception\fixtures\WallEntryFixture;
use tests\codeception\fixtures\ContentFixture;
use tests\codeception\fixtures\PostFixture;
use tests\codeception\fixtures\UserFollowFixture;
@ -18,7 +16,6 @@ use humhub\modules\post\models\Post;
use humhub\modules\dashboard\components\actions\DashboardStream;
use humhub\modules\user\models\User;
use humhub\modules\space\models\Space;
use humhub\modules\activity\models\Activity;
use humhub\modules\content\models\Content;
class DashboardStreamTest extends DbTestCase
@ -47,12 +44,6 @@ class DashboardStreamTest extends DbTestCase
'space_membership' => [
'class' => SpaceMembershipFixture::className(),
],
'wall' => [
'class' => WallFixture::className(),
],
'wall_entry' => [
'class' => WallEntryFixture::className(),
],
'content' => [
'class' => ContentFixture::className(),
],
@ -69,19 +60,21 @@ class DashboardStreamTest extends DbTestCase
{
$this->becomeUser('User2');
$post1 = new Post;
$post1 = new Post();
$post1->message = "Private Post";
$post1->content->container = Yii::$app->user->getIdentity();
$post1->content->visibility = Content::VISIBILITY_PRIVATE;
$post1->save();
$w1 = $post1->content->getFirstWallEntryId();
$w1 = $post1->content->id;
$post2 = new Post;
$post2 = new Post();
$post2->message = "Public Post";
$post2->content->container = Yii::$app->user->getIdentity();
$post2->content->visibility = Content::VISIBILITY_PUBLIC;
$post2->save();
$w2 = $post2->content->getFirstWallEntryId();
$w2 = $post2->content->id;
$this->becomeUser('Admin');
$ids = $this->getStreamActionIds(2);
@ -93,7 +86,7 @@ class DashboardStreamTest extends DbTestCase
/**
* if a user follows a space is the PUBLIC post included
* the private not
*/
*/
public function testSpaceFollow()
{
$this->becomeUser('User2');
@ -104,14 +97,14 @@ class DashboardStreamTest extends DbTestCase
$post1->content->setContainer($space);
$post1->content->visibility = Content::VISIBILITY_PRIVATE;
$post1->save();
$w1 = $post1->content->getFirstWallEntryId();
$w1 = $post1->content->id;
$post2 = new Post;
$post2->message = "Public Post";
$post2->content->setContainer($space);
$post2->content->visibility = Content::VISIBILITY_PUBLIC;
$post2->save();
$w2 = $post2->content->getFirstWallEntryId();
$w2 = $post2->content->id;
$this->becomeUser('Admin');
@ -124,7 +117,7 @@ class DashboardStreamTest extends DbTestCase
/**
* When member of a space, public & private content should returned.
* When no member no content should be returned.
*/
*/
public function testSpaceMembership()
{
$this->becomeUser('Admin');
@ -135,14 +128,14 @@ class DashboardStreamTest extends DbTestCase
$post1->content->setContainer($space);
$post1->content->visibility = Content::VISIBILITY_PRIVATE;
$post1->save();
$w1 = $post1->content->getFirstWallEntryId();
$w1 = $post1->content->id;
$post2 = new Post;
$post2->message = "Public Post";
$post2->content->setContainer($space);
$post2->content->visibility = Content::VISIBILITY_PUBLIC;
$post2->save();
$w2 = $post2->content->getFirstWallEntryId();
$w2 = $post2->content->id;
$this->assertEquals($this->getStreamActionIds(2), array($w2, $w1));
@ -154,7 +147,7 @@ class DashboardStreamTest extends DbTestCase
/**
* Own profile content should appear with visibility Private & Public
*/
*/
public function testOwnContent()
{
$this->becomeUser('Admin');
@ -164,14 +157,14 @@ class DashboardStreamTest extends DbTestCase
$post1->content->container = Yii::$app->user->getIdentity();
$post1->content->visibility = Content::VISIBILITY_PRIVATE;
$post1->save();
$w1 = $post1->content->getFirstWallEntryId();
$w1 = $post1->content->id;
$post2 = new Post;
$post2->message = "Own Public Post";
$post2->content->container = Yii::$app->user->getIdentity();
$post2->content->visibility = Content::VISIBILITY_PUBLIC;
$post2->save();
$w2 = $post2->content->getFirstWallEntryId();
$w2 = $post2->content->id;
$ids = $this->getStreamActionIds(2);
$this->assertEquals($ids, array($w2, $w1));
@ -182,11 +175,11 @@ class DashboardStreamTest extends DbTestCase
$action = new DashboardStream('stream', Yii::$app->controller, [
'limit' => $limit,
]);
$wallEntries = $action->getWallEntries();
$wallEntryIds = array_map(create_function('$entry', 'return $entry->id;'), $wallEntries);
return $wallEntryIds;
$action->init();
$streamEntries = $action->activeQuery->all();
return array_map(create_function('$entry', 'return $entry->id;'), $streamEntries);
}
private function becomeUser($userName)