Inheritance: extends CMSx\Auth\User
コード例 #1
0
 public function testUnsaved()
 {
     $user = $this->testUser->getUser();
     $bp = BotPassword::newUnsaved(['user' => $user, 'appId' => 'DoesNotExist']);
     $this->assertInstanceOf('BotPassword', $bp);
     $this->assertFalse($bp->isSaved());
     $this->assertSame(42, $bp->getUserCentralId());
     $this->assertSame('DoesNotExist', $bp->getAppId());
     $this->assertEquals(MWRestrictions::newDefault(), $bp->getRestrictions());
     $this->assertSame([], $bp->getGrants());
     $bp = BotPassword::newUnsaved(['username' => 'UTDummy', 'appId' => 'DoesNotExist2', 'restrictions' => MWRestrictions::newFromJson('{"IPAddresses":["127.0.0.0/8"]}'), 'grants' => ['test']]);
     $this->assertInstanceOf('BotPassword', $bp);
     $this->assertFalse($bp->isSaved());
     $this->assertSame(43, $bp->getUserCentralId());
     $this->assertSame('DoesNotExist2', $bp->getAppId());
     $this->assertEquals('{"IPAddresses":["127.0.0.0/8"]}', $bp->getRestrictions()->toJson());
     $this->assertSame(['test'], $bp->getGrants());
     $user = $this->testUser->getUser();
     $bp = BotPassword::newUnsaved(['centralId' => 45, 'appId' => 'DoesNotExist']);
     $this->assertInstanceOf('BotPassword', $bp);
     $this->assertFalse($bp->isSaved());
     $this->assertSame(45, $bp->getUserCentralId());
     $this->assertSame('DoesNotExist', $bp->getAppId());
     $user = $this->testUser->getUser();
     $bp = BotPassword::newUnsaved(['user' => $user, 'appId' => 'BotPassword']);
     $this->assertInstanceOf('BotPassword', $bp);
     $this->assertFalse($bp->isSaved());
     $this->assertNull(BotPassword::newUnsaved(['user' => $user, 'appId' => '']));
     $this->assertNull(BotPassword::newUnsaved(['user' => $user, 'appId' => str_repeat('X', BotPassword::APPID_MAXLENGTH + 1)]));
     $this->assertNull(BotPassword::newUnsaved(['user' => $this->testUserName, 'appId' => 'Ok']));
     $this->assertNull(BotPassword::newUnsaved(['username' => 'UTInvalid', 'appId' => 'Ok']));
     $this->assertNull(BotPassword::newUnsaved(['appId' => 'Ok']));
 }
 public function testGetEntityParserOutputGenerator_noParserOptionLanguage()
 {
     $parserOutputGeneratorFactory = $this->getEntityParserOutputGeneratorFactory();
     $testUser = new \TestUser('Wikibase User');
     $instance = $parserOutputGeneratorFactory->getEntityParserOutputGenerator(new ParserOptions($testUser->getUser()));
     $this->assertInstanceOf('Wikibase\\Repo\\ParserOutput\\EntityParserOutputGenerator', $instance);
 }
コード例 #3
0
ファイル: Test.php プロジェクト: hochla-simon/Pitter
 public function testUser()
 {
     $test = new TestUser();
     $test->testEditProfile();
     $test->testLogin();
     $test->testRecoverPassword();
     $test->testRegister();
 }
コード例 #4
0
 protected function setUp()
 {
     parent::setUp();
     $testUser = new \TestUser('ActionTestUser');
     $user = $testUser->getUser();
     $user->setId(123456789);
     $this->setMwGlobals(array('wgUser' => $user, 'wgLang' => Language::factory($this->languageCode), 'wgRequest' => new FauxRequest(), 'wgGroupPermissions' => array('*' => array('edit' => true, 'read' => true))));
     ApiQueryInfo::resetTokenCache();
 }
コード例 #5
0
 public function testDropTable()
 {
     //Build the table and database as needed, load test user
     DinklyBuilder::buildTable('unit_test', 'TestUser', null, false);
     DinklyBuilder::loadAllFixtures('unit_test', false);
     //Test that we have a hyrdrated user model to work with
     $user = new TestUser();
     $this->assertTrue($user->init(1));
     //Test the successful removal of the table
     $this->assertTrue(DinklyBuilder::dropTable('unit_test', 'TestUser'));
 }
コード例 #6
0
 public function testInitMoreData()
 {
     $user = new TestUser();
     $user->name = 'test user';
     $user->save();
     $movie = new TestMovie();
     $movie->name = 'test movie';
     $movie->save();
     $movie = new TestMovie();
     $movie->name = 'test movie 2';
     $movie->save();
     $this->conn->clear();
 }
コード例 #7
0
 private function getSome()
 {
     for ($i = 1; $i < 3; ++$i) {
         $this->assertTrue(TestUser::dao()->getByLogic(Expression::eq('city_id', $i)) == TestUser::dao()->getById($i));
     }
     $this->assertEquals(count(TestUser::dao()->getPlainList()), count(TestCity::dao()->getPlainList()));
 }
コード例 #8
0
 function addDBData()
 {
     // ensure the correct default gender
     $this->mergeMwGlobalArrayValue('wgDefaultUserOptions', array('gender' => 'unknown'));
     $user = User::newFromName('UTMale');
     if ($user->getID() == 0) {
         $user->addToDatabase();
         TestUser::setPasswordForUser($user, 'UTMalePassword');
     }
     // ensure the right gender
     $user->setOption('gender', 'male');
     $user->saveSettings();
     $user = User::newFromName('UTFemale');
     if ($user->getID() == 0) {
         $user->addToDatabase();
         TestUser::setPasswordForUser($user, 'UTFemalePassword');
     }
     // ensure the right gender
     $user->setOption('gender', 'female');
     $user->saveSettings();
     $user = User::newFromName('UTDefaultGender');
     if ($user->getID() == 0) {
         $user->addToDatabase();
         TestUser::setPasswordForUser($user, 'UTDefaultGenderPassword');
     }
     // ensure the default gender
     $user->setOption('gender', null);
     $user->saveSettings();
 }
コード例 #9
0
 public function testWithObjects()
 {
     $criteria = Criteria::create(TestUser::dao())->add(Expression::containsIp(IpRange::create('192.168.1.1-192.168.1.255'), 'ip'))->addProjection(Projection::property('id'));
     $this->assertEquals($criteria->toDialectString(PostgresDialect::me()), 'SELECT "test_user"."id" FROM "test_user" WHERE "test_user"."ip" <<= \'192.168.1.1-192.168.1.255\'');
     $criteria = Criteria::create(TestInternetProvider::dao())->add(Expression::containsIp('range', IpAddress::create('42.42.42.42')))->addProjection(Projection::property('id'));
     $this->assertEquals($criteria->toDialectString(PostgresDialect::me()), 'SELECT "test_internet_provider"."id" FROM "test_internet_provider" WHERE \'42.42.42.42\' <<= "test_internet_provider"."range"');
 }
コード例 #10
0
 /**
  * Install hstore
  * /usr/share/postgresql/contrib # cat hstore.sql | psql -U pgsql -d onphp
  **/
 public function testHstore()
 {
     foreach (DBTestPool::me()->getPool() as $connector => $db) {
         DBPool::me()->setDefault($db);
         $properties = array('age' => '23', 'weight' => 80, 'comment' => null);
         $user = TestUser::create()->setCity($moscow = TestCity::create()->setName('Moscow'))->setCredentials(Credentials::create()->setNickname('fake')->setPassword(sha1('passwd')))->setLastLogin(Timestamp::create(time()))->setRegistered(Timestamp::create(time())->modify('-1 day'))->setProperties(Hstore::make($properties));
         $moscow = TestCity::dao()->add($moscow);
         $user = TestUser::dao()->add($user);
         Cache::me()->clean();
         TestUser::dao()->dropIdentityMap();
         $user = TestUser::dao()->getById('1');
         $this->assertInstanceOf('Hstore', $user->getProperties());
         $this->assertEquals($properties, $user->getProperties()->getList());
         $form = TestUser::proto()->makeForm();
         $form->get('properties')->setFormMapping(array(Primitive::string('age'), Primitive::integer('weight'), Primitive::string('comment')));
         $form->import(array('id' => $user->getId()));
         $this->assertNotNull($form->getValue('id'));
         $object = $user;
         FormUtils::object2form($object, $form);
         $this->assertInstanceOf('Hstore', $form->getValue('properties'));
         $this->assertEquals(array_filter($properties), $form->getValue('properties')->getList());
         $subform = $form->get('properties')->getInnerForm();
         $this->assertEquals($subform->getValue('age'), '23');
         $this->assertEquals($subform->getValue('weight'), 80);
         $this->assertNull($subform->getValue('comment'));
         $user = new TestUser();
         FormUtils::form2object($form, $user, false);
         $this->assertEquals($user->getProperties()->getList(), array_filter($properties));
     }
 }
コード例 #11
0
 public function testRegistration()
 {
     $auth = $this->di->get('auth');
     /* Test successful registration */
     $result = $auth->registerUser(array('username' => 'test_1', 'email' => '*****@*****.**', 'password' => 'test_test_test', 'password_confirm' => 'test_test_test'));
     $this->assertEquals(count($result), 0, 'Failures when registering user');
     $user = TestUser::findFirst(array('username = :username:'******'bind' => array('username' => 'test_1')));
     $this->assertNotEquals($user, FALSE, 'Registered user not found in database');
     /* End test */
     /* Test invalid email registration */
     $result = $auth->registerUser(array('username' => 'test_2', 'email' => 'test', 'password' => 'test_test_test', 'password_confirm' => 'test_test_test'));
     $this->assertNotEquals(count($result), 0, 'No failures when registering user, failures expected');
     $user = TestUser::findFirst(array('username = :username:'******'bind' => array('username' => 'test_2')));
     $this->assertEquals($user, FALSE, 'User found in database that should have failed');
     /* End test */
     /* Test different password registration */
     $result = $auth->registerUser(array('username' => 'test_3', 'email' => '*****@*****.**', 'password' => 'some_pass', 'password_confirm' => 'some_other_pass'));
     $this->assertNotEquals(count($result), 0, 'No failures when registering user, failures expected');
     $user = TestUser::findFirst(array('username = :username:'******'bind' => array('username' => 'test_3')));
     $this->assertEquals($user, FALSE, 'User found in database that should have failed');
     /* End test */
     /* Test invalid password registration */
     $result = $auth->registerUser(array('username' => 'test_4', 'email' => '*****@*****.**', 'password' => 'short', 'password_confirm' => 'short'));
     $this->assertNotEquals(count($result), 0, 'No failures when registering user, failures expected');
     $user = TestUser::findFirst(array('username = :username:'******'bind' => array('username' => 'test_4')));
     $this->assertEquals($user, FALSE, 'User found in database that should have failed');
     /* End test */
     /* Test register empty user */
     $result = $auth->registerUser(array('username' => '', 'email' => '', 'password' => '', 'password_confirm' => ''));
     $this->assertNotEquals(count($result), 0, 'No failures when registering, failures expected');
     $user = TestUser::findFirst(array('username = :username:'******'bind' => array('username' => '')));
     $this->assertEquals($user, FALSE, 'User found in database that should have failed');
     /* End test */
 }
コード例 #12
0
 function addDBData()
 {
     $user = User::newFromName('UTApiBlockee');
     if ($user->getId() == 0) {
         $user->addToDatabase();
         TestUser::setPasswordForUser($user, 'UTApiBlockeePassword');
         $user->saveSettings();
     }
 }
コード例 #13
0
ファイル: UserRoleTest.php プロジェクト: anlutro/access
 public function testRemoveUserRole()
 {
     $user = TestUser::create(['name' => 'user']);
     $role = Role::create(['name' => 'role']);
     $user->addRole($role);
     $user->removeRole($role);
     $this->assertFalse($user->roles->contains($role->getKey()));
     $this->assertFalse($role->users->contains($user->getKey()));
 }
コード例 #14
0
 private function getByEmptyIdTest($id)
 {
     try {
         TestUser::dao()->getById($id);
         $this->fail();
     } catch (WrongArgumentException $e) {
         // pass
     }
 }
コード例 #15
0
 public function testDialectStringObjects()
 {
     $criteria = Criteria::create(TestUser::dao())->setProjection(Projection::property('id'))->add(Expression::gt('registered', Date::create('2011-01-01')));
     $this->assertEquals($criteria->toDialectString(ImaginaryDialect::me()), 'SELECT test_user.id FROM test_user WHERE (test_user.registered > 2011-01-01)');
     $criteria = Criteria::create(TestUserWithContactExtended::dao())->setProjection(Projection::property('contactExt.city.id', 'cityId'))->add(Expression::eq('contactExt.city', TestCity::create()->setId(22)));
     $this->assertEquals($criteria->toDialectString(ImaginaryDialect::me()), 'SELECT test_user_with_contact_extended.city_id AS cityId FROM test_user_with_contact_extended WHERE (test_user_with_contact_extended.city_id = 22)');
     $cityList = array(TestCity::create()->setId(3), TestCity::create()->setId(44));
     $criteria = Criteria::create(TestUser::dao())->setProjection(Projection::property('id'))->add(Expression::in('city', $cityList));
     $this->assertEquals($criteria->toDialectString(ImaginaryDialect::me()), 'SELECT test_user.id FROM test_user WHERE (test_user.city_id IN (3, 44))');
 }
コード例 #16
0
 public function testUserPermissionComesBeforeRolePermission()
 {
     $user = TestUser::create(['name' => 'user']);
     $role = Role::create(['name' => 'role']);
     $perm = Permission::create(['name' => 'permission']);
     $user->addRole($role);
     $role->allowPermission($perm);
     $user->denyPermission($perm);
     $perm = $user->getPermission($perm);
     $this->assertNotNull($perm);
     $this->assertFalse($perm->allow);
 }
コード例 #17
0
ファイル: Info.php プロジェクト: mjrao/BugFree
 protected function afterValidate()
 {
     //check product permission
     if (!self::isProductAccessable($this->product_id)) {
         $this->addError('product_id', $this->getAttributeLabel('product_id') . ' ' . Yii::t('Product', 'No access right to this product'));
     }
     //set modified_by
     if ($this->isNewRecord) {
         $this->modified_by = $this->updated_by;
     } else {
         $dbBugInfo = $this->model()->findByPk($this->id);
         $oldModifiedBy = $dbBugInfo->modified_by;
         if (!in_array($this->updated_by, CommonService::splitStringToArray(',', $oldModifiedBy))) {
             if (empty($this->modified_by)) {
                 $this->modified_by = $this->updated_by;
             } else {
                 $this->modified_by .= ',' . $this->updated_by;
             }
         }
     }
     //set productmodule_id to be null if productmodule_id = 0
     if (0 == $this->productmodule_id) {
         $this->productmodule_id = null;
     }
     //filter duplicated mail_to
     if (!empty($this->mail_to)) {
         $this->mail_to = join(',', CommonService::splitStringToArray(',', $this->mail_to));
     }
     //set assign_to
     if (!empty($this->assign_to_name)) {
         if (TestUser::ACTIVE_USER_NAME == $this->assign_to_name) {
             $this->assign_to = TestUser::ACTIVE_USER_ID;
         } else {
             if (TestUser::CLOSE_USER_NAME == $this->assign_to_name) {
                 $this->assign_to = TestUser::CLOSE_USER_ID;
             } else {
                 $assigntoInfo = TestUser::model()->findByAttributes(array('realname' => $this->assign_to_name));
                 if ($assigntoInfo !== null) {
                     $this->assign_to = $assigntoInfo->id;
                 } else {
                     $assigntoNameError = $this->getError('assign_to_name');
                     if (empty($assigntoNameError)) {
                         $this->addError('assign_to_name', $this->getAttributeLabel('assign_to_name') . ' ' . Yii::t('TestUser', 'user not found'));
                     }
                 }
             }
         }
     } else {
         $this->assign_to = null;
     }
     return parent::afterValidate();
 }
コード例 #18
0
ファイル: SearchController.php プロジェクト: riccoyu/BugFree
 public function actionGetModuleOwner()
 {
     $moduleId = $_GET['module_id'];
     $moduleInfo = ProductModule::model()->findByPk($moduleId);
     $owner = '';
     if ($moduleInfo != null && !empty($moduleInfo->owner)) {
         $ownerInfo = TestUser::model()->findByPk($moduleInfo->owner);
         if ($ownerInfo != null) {
             $owner = $ownerInfo->realname;
         }
     }
     echo $owner;
 }
コード例 #19
0
ファイル: UserWrapper.php プロジェクト: claudinec/galan-wiki
 public function __construct($userName, $password, $group = '')
 {
     $this->userName = $userName;
     $this->password = $password;
     $this->user = User::newFromName($this->userName);
     if (!$this->user->getId()) {
         $this->user = User::createNew($this->userName, ["email" => "*****@*****.**", "real_name" => "Test User"]);
     }
     TestUser::setPasswordForUser($this->user, $this->password);
     if ($group !== '') {
         $this->user->addGroup($group);
     }
     $this->user->saveSettings();
 }
コード例 #20
0
 /**
  * Get a TestUser object that the caller may not modify.
  *
  * Whenever possible, unit tests should use immutable users, because
  * immutable users can be reused in multiple tests, which helps keep
  * the unit tests fast.
  *
  * @since 1.28
  *
  * @param string[] $groups Groups the test user should be added to.
  * @return TestUser
  */
 public static function getImmutableTestUser($groups = [])
 {
     $groups = array_unique($groups);
     sort($groups);
     $key = implode(',', $groups);
     $testUser = isset(self::$testUsers[$key]) ? self::$testUsers[$key] : false;
     if (!$testUser || !$testUser->getUser()->isLoggedIn()) {
         $id = self::getNextId();
         // Hack! If this is the primary sysop account, make the username
         // be 'UTSysop', for back-compat, and for the sake of PHPUnit data
         // provider methods, which are executed before the test database
         // is set up. See T136348.
         if ($groups === ['bureaucrat', 'sysop']) {
             $username = '******';
             $password = '******';
         } else {
             $username = "******";
             $password = wfRandomString(20);
         }
         self::$testUsers[$key] = $testUser = new TestUser($username, "Name {$id}", "{$id}@mediawiki.test", $groups, $password);
     }
     $testUser->getUser()->clearInstanceCache();
     return self::$testUsers[$key];
 }
コード例 #21
0
ファイル: BotPasswordTest.php プロジェクト: paladox/mediawiki
 public function testLogin()
 {
     // Test failure when bot passwords aren't enabled
     $this->setMwGlobals('wgEnableBotPasswords', false);
     $status = BotPassword::login("{$this->testUserName}@BotPassword", 'foobaz', new FauxRequest());
     $this->assertEquals(Status::newFatal('botpasswords-disabled'), $status);
     $this->setMwGlobals('wgEnableBotPasswords', true);
     // Test failure when BotPasswordSessionProvider isn't configured
     $manager = new SessionManager(['logger' => new Psr\Log\NullLogger(), 'store' => new EmptyBagOStuff()]);
     $reset = MediaWiki\Session\TestUtils::setSessionManagerSingleton($manager);
     $this->assertNull($manager->getProvider(MediaWiki\Session\BotPasswordSessionProvider::class), 'sanity check');
     $status = BotPassword::login("{$this->testUserName}@BotPassword", 'foobaz', new FauxRequest());
     $this->assertEquals(Status::newFatal('botpasswords-no-provider'), $status);
     ScopedCallback::consume($reset);
     // Now configure BotPasswordSessionProvider for further tests...
     $mainConfig = RequestContext::getMain()->getConfig();
     $config = new HashConfig(['SessionProviders' => $mainConfig->get('SessionProviders') + [MediaWiki\Session\BotPasswordSessionProvider::class => ['class' => MediaWiki\Session\BotPasswordSessionProvider::class, 'args' => [['priority' => 40]]]]]);
     $manager = new SessionManager(['config' => new MultiConfig([$config, RequestContext::getMain()->getConfig()]), 'logger' => new Psr\Log\NullLogger(), 'store' => new EmptyBagOStuff()]);
     $reset = MediaWiki\Session\TestUtils::setSessionManagerSingleton($manager);
     // No "@"-thing in the username
     $status = BotPassword::login($this->testUserName, 'foobaz', new FauxRequest());
     $this->assertEquals(Status::newFatal('botpasswords-invalid-name', '@'), $status);
     // No base user
     $status = BotPassword::login('UTDummy@BotPassword', 'foobaz', new FauxRequest());
     $this->assertEquals(Status::newFatal('nosuchuser', 'UTDummy'), $status);
     // No bot password
     $status = BotPassword::login("{$this->testUserName}@DoesNotExist", 'foobaz', new FauxRequest());
     $this->assertEquals(Status::newFatal('botpasswords-not-exist', $this->testUserName, 'DoesNotExist'), $status);
     // Failed restriction
     $request = $this->getMock('FauxRequest', ['getIP']);
     $request->expects($this->any())->method('getIP')->will($this->returnValue('10.0.0.1'));
     $status = BotPassword::login("{$this->testUserName}@BotPassword", 'foobaz', $request);
     $this->assertEquals(Status::newFatal('botpasswords-restriction-failed'), $status);
     // Wrong password
     $status = BotPassword::login("{$this->testUserName}@BotPassword", $this->testUser->getPassword(), new FauxRequest());
     $this->assertEquals(Status::newFatal('wrongpassword'), $status);
     // Success!
     $request = new FauxRequest();
     $this->assertNotInstanceOf(MediaWiki\Session\BotPasswordSessionProvider::class, $request->getSession()->getProvider(), 'sanity check');
     $status = BotPassword::login("{$this->testUserName}@BotPassword", 'foobaz', $request);
     $this->assertInstanceOf('Status', $status);
     $this->assertTrue($status->isGood());
     $session = $status->getValue();
     $this->assertInstanceOf(MediaWiki\Session\Session::class, $session);
     $this->assertInstanceOf(MediaWiki\Session\BotPasswordSessionProvider::class, $session->getProvider());
     $this->assertSame($session->getId(), $request->getSession()->getId());
     ScopedCallback::consume($reset);
 }
コード例 #22
0
 public function testIpAddressProperty()
 {
     foreach (DBTestPool::me()->getPool() as $db) {
         DBPool::me()->setDefault($db);
         $city = TestCity::create()->setName('Khimki');
         TestCity::dao()->add($city);
         $userWithIp = TestUser::create()->setCredentials(Credentials::create()->setNickName('postgreser')->setPassword(sha1('postgreser')))->setLastLogin(Timestamp::makeNow())->setRegistered(Timestamp::makeNow())->setCity($city)->setIp(IpAddress::create('127.0.0.1'));
         TestUser::dao()->add($userWithIp);
         $this->assertTrue($userWithIp->getId() >= 1);
         $this->assertTrue($userWithIp->getIp() instanceof IpAddress);
         $plainIp = DBPool::me()->getByDao(TestUser::dao())->queryColumn(OSQL::select()->get('ip')->from(TestUser::dao()->getTable())->where(Expression::eq('id', $userWithIp->getId())));
         $this->assertEquals($plainIp[0], $userWithIp->getIp()->toString());
         $count = Criteria::create(TestUser::dao())->add(Expression::eq('ip', IpAddress::create('127.0.0.1')))->addProjection(Projection::count('*', 'count'))->getCustom('count');
         $this->assertEquals($count, 1);
     }
 }
コード例 #23
0
ファイル: UserTest.php プロジェクト: laiello/plankonindia
 /**
  * testDeleteUsers
  */
 public function testDeleteUsers()
 {
     // delete normal user
     $this->User->id = 3;
     $result = $this->User->delete();
     $this->assertTrue($result);
     // delete an admin
     $this->User->id = 2;
     $result = $this->User->delete();
     $this->assertTrue($result);
     // delete last remaining admin
     $this->User->id = 1;
     $result = $this->User->delete();
     $this->assertFalse($result);
     $count = $this->User->find('count');
     $this->assertEquals(1, $count);
 }
コード例 #24
0
 public function unified()
 {
     $user = TestUser::dao()->getById(1);
     $encapsulant = TestEncapsulant::dao()->getPlainList();
     $collectionDao = $user->getEncapsulants();
     $collectionDao->fetch()->setList($encapsulant);
     $collectionDao->save();
     unset($collectionDao);
     // fetch
     $encapsulantsList = $user->getEncapsulants()->getList();
     $piter = TestCity::dao()->getById(1);
     $moscow = TestCity::dao()->getById(2);
     for ($i = 0; $i < 10; $i++) {
         $this->assertEquals($encapsulantsList[$i]->getId(), $i + 1);
         $this->assertEquals($encapsulantsList[$i]->getName(), $i);
         $cityList = $encapsulantsList[$i]->getCities()->getList();
         $this->assertEquals($cityList[0], $piter);
         $this->assertEquals($cityList[1], $moscow);
     }
     unset($encapsulantsList);
     // lazy fetch
     $encapsulantsList = $user->getEncapsulants(true)->getList();
     for ($i = 1; $i < 11; $i++) {
         $this->assertEquals($encapsulantsList[$i], $i);
     }
     // count
     $user->getEncapsulants()->clean();
     $this->assertEquals($user->getEncapsulants()->getCount(), 10);
     $criteria = Criteria::create(TestEncapsulant::dao())->add(Expression::in('cities.id', array($piter->getId(), $moscow->getId())));
     $user->getEncapsulants()->setCriteria($criteria);
     $this->assertEquals($user->getEncapsulants()->getCount(), 20);
     // distinct count
     $user->getEncapsulants()->clean();
     $user->getEncapsulants()->setCriteria($criteria->setDistinct(true));
     if (DBPool::me()->getLink() instanceof SQLite) {
         // TODO: sqlite does not support such queries yet
         return null;
     }
     $this->assertEquals($user->getEncapsulants()->getCount(), 10);
 }
コード例 #25
0
        <link rel="stylesheet" type="text/css" href="./cloud/assets/css/testapicss.css" />
    </head>
    <body>
        <div class="banner">
            <a class="btn-brand" style="vertical-align:middle;" href='http://wiki.open.b.qq.com/start' target="_blank" title="API文档">企业QQ开放平台</a>
            <?php 
if (TestUser::user()->isLogin()) {
    ?>
                <label for="openid">当前登录open_id:</label>
                <span><?php 
    echo TestUser::user()->id();
    ?>
</span> 
                <label for="companyid" >company_id:</label>
                <span><?php 
    echo TestUser::user()->companyId();
    ?>
</span>
                <a class="btn-violet btn-login" href="./cloud/logout.php">退出登录</a>
                <?php 
} else {
    ?>
                <span style="margin-left: 20px;vertical-align:middle;">请登录:</span>
                <a href="<?php 
    echo $url;
    ?>
" target="_blank"><img style="vertical-align:middle;" src="./cloud/assets/images/qqeim_login.gif"/></a>
                <span class="hintlogin"><==&nbsp;使用示例APP请先登录</span>
            <?php 
}
?>
コード例 #26
0
 public function testUserWithNoWatchedItems_displaysNoWatchlistMessage()
 {
     $user = new TestUser(__METHOD__);
     list($html, ) = $this->executeSpecialPage('', null, 'qqx', $user->getUser());
     $this->assertContains('(nowatchlist)', $html);
 }
コード例 #27
0
<?php

require '../../../lib.php';
$openId = TestUser::user()->id();
$companyId = TestUser::user()->companyId();
$model = new CSCorpModel();
$api = OpenHelper::api();
$result = $api->getUserMobile($companyId, $model->getToken($companyId), getClientIp(), $openId);
OpenUtils::outputJson($result);
コード例 #28
0
ファイル: TestCase.php プロジェクト: dvlpp/merx
 protected function loginClient()
 {
     $user = TestUser::create();
     auth()->login($user);
     return $user;
 }
コード例 #29
0
 private function addCoreDBData()
 {
     if ($this->db->getType() == 'oracle') {
         # Insert 0 user to prevent FK violations
         # Anonymous user
         $this->db->insert('user', array('user_id' => 0, 'user_name' => 'Anonymous'), __METHOD__, array('IGNORE'));
         # Insert 0 page to prevent FK violations
         # Blank page
         $this->db->insert('page', array('page_id' => 0, 'page_namespace' => 0, 'page_title' => ' ', 'page_restrictions' => null, 'page_is_redirect' => 0, 'page_is_new' => 0, 'page_random' => 0, 'page_touched' => $this->db->timestamp(), 'page_latest' => 0, 'page_len' => 0), __METHOD__, array('IGNORE'));
     }
     User::resetIdByNameCache();
     // Make sysop user
     $user = User::newFromName('UTSysop');
     if ($user->idForName() == 0) {
         $user->addToDatabase();
         TestUser::setPasswordForUser($user, 'UTSysopPassword');
     }
     // Always set groups, because $this->resetDB() wipes them out
     $user->addGroup('sysop');
     $user->addGroup('bureaucrat');
     // Make 1 page with 1 revision
     $page = WikiPage::factory(Title::newFromText('UTPage'));
     if ($page->getId() == 0) {
         $page->doEditContent(new WikitextContent('UTContent'), 'UTPageSummary', EDIT_NEW, false, $user);
         // doEditContent() probably started the session via
         // User::loadFromSession(). Close it now.
         if (session_id() !== '') {
             session_write_close();
             session_id('');
         }
     }
 }
コード例 #30
0
<?php

require '../lib.php';
TestUser::user()->logout();
header('Location:../');