diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/all_tests.php | 26 | ||||
-rwxr-xr-x | tests/config_test.php | 12 | ||||
-rwxr-xr-x | tests/modules/Common.test.php | 50 | ||||
-rw-r--r-- | tests/modules/LogStats_Db.test.php | 74 | ||||
-rw-r--r-- | tests/modules/PHP_Related.test.php | 74 | ||||
-rw-r--r-- | tests/modules/Period.test.php | 238 | ||||
-rw-r--r-- | tests/modules/Piwik.test.php | 22 | ||||
-rwxr-xr-x | tests/modules/SitesManager.test.php | 12 | ||||
-rwxr-xr-x | tests/modules/TablePartitioning.test.php | 2 | ||||
-rw-r--r-- | tests/modules/UsersManager.test.php | 152 |
10 files changed, 331 insertions, 331 deletions
diff --git a/tests/all_tests.php b/tests/all_tests.php index 64399e3314..98d2a9c894 100755 --- a/tests/all_tests.php +++ b/tests/all_tests.php @@ -1,21 +1,21 @@ <?php flush(); -require_once "config_test.php";
+require_once "config_test.php"; Piwik::createConfigObject(); $databaseTestName = Zend_Registry::get('config')->database_tests->dbname; -Zend_Registry::get('config')->doWriteFileWhenUpdated = false;
-?>
-
-<h2>Piwik unit tests</h2>
-<p>Some of the tests require a database access. The database used for tests is different from your normal Piwik database.
-You may need to create this database ; you can edit the settings for the unit tests database access in your config file
-/config/global.ini.php</p>
-<p><b>The database used in your tests is called "<?php echo $databaseTestName; ?>". Create it if necessary.</b></p>
-<p><a href='modules'>Run the tests by module</a></p>
-<hr>
-
-<?php
+Zend_Registry::get('config')->doWriteFileWhenUpdated = false; +?> + +<h2>Piwik unit tests</h2> +<p>Some of the tests require a database access. The database used for tests is different from your normal Piwik database. +You may need to create this database ; you can edit the settings for the unit tests database access in your config file +/config/global.ini.php</p> +<p><b>The database used in your tests is called "<?php echo $databaseTestName; ?>". Create it if necessary.</b></p> +<p><a href='modules'>Run the tests by module</a></p> +<hr> + +<?php /* assertTrue($x) Fail if $x is false assertFalse($x) Fail if $x is true diff --git a/tests/config_test.php b/tests/config_test.php index 2b7c563098..b2cc28716c 100755 --- a/tests/config_test.php +++ b/tests/config_test.php @@ -11,11 +11,11 @@ if(!defined("PATH_TEST_TO_ROOT2")) if(!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', PATH_TEST_TO_ROOT); -}
+} -set_include_path( PATH_TEST_TO_ROOT .'/'
- . PATH_SEPARATOR . PATH_TEST_TO_ROOT .'/../'
- . PATH_SEPARATOR . '../' . PATH_TEST_TO_ROOT
+set_include_path( PATH_TEST_TO_ROOT .'/' + . PATH_SEPARATOR . PATH_TEST_TO_ROOT .'/../' + . PATH_SEPARATOR . '../' . PATH_TEST_TO_ROOT . PATH_SEPARATOR . getcwd() . PATH_SEPARATOR . getcwd() . '/../' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 @@ -40,8 +40,8 @@ set_include_path( PATH_TEST_TO_ROOT .'/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/plugins/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/modules/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/tests/' - . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/'
- . PATH_SEPARATOR . get_include_path()
+ . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/' + . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . get_include_path() . '../' ); diff --git a/tests/modules/Common.test.php b/tests/modules/Common.test.php index 3126c2fca7..42c66ab14b 100755 --- a/tests/modules/Common.test.php +++ b/tests/modules/Common.test.php @@ -440,31 +440,31 @@ class Test_Piwik_Common extends UnitTestCase $expectedResult = 'Поиск в Интернете Поиск страниц на русском _*()!$!£$^!£$%'; $expectedResult = htmlentities($expectedResult); $this->assertEqual($result, $expectedResult); - }
-
-
- public function test_isValidFilenameValidValues()
- {
-
- $valid = array(
- "test", "test.txt","test.......", "en-ZHsimplified",
- );
- foreach($valid as $toTest)
- {
- $this->assertTrue(Piwik_Common::isValidFilename($toTest), $toTest." not valid!");
- }
- }
- public function test_isValidFilenameNotValidValues()
- {
-
- $notvalid = array(
- "../test", "/etc/htpasswd", '$var', ';test', '[bizarre]', '', ".htaccess", "very long long eogaioge ageja geau ghaeihieg heiagie aiughaeui hfilename",
- );
- foreach($notvalid as $toTest)
- {
- $this->assertFalse(Piwik_Common::isValidFilename($toTest), $toTest." valid but shouldn't!");
- }
- }
+ } + + + public function test_isValidFilenameValidValues() + { + + $valid = array( + "test", "test.txt","test.......", "en-ZHsimplified", + ); + foreach($valid as $toTest) + { + $this->assertTrue(Piwik_Common::isValidFilename($toTest), $toTest." not valid!"); + } + } + public function test_isValidFilenameNotValidValues() + { + + $notvalid = array( + "../test", "/etc/htpasswd", '$var', ';test', '[bizarre]', '', ".htaccess", "very long long eogaioge ageja geau ghaeihieg heiagie aiughaeui hfilename", + ); + foreach($notvalid as $toTest) + { + $this->assertFalse(Piwik_Common::isValidFilename($toTest), $toTest." valid but shouldn't!"); + } + } } diff --git a/tests/modules/LogStats_Db.test.php b/tests/modules/LogStats_Db.test.php index e611d3089f..43ccb743b8 100644 --- a/tests/modules/LogStats_Db.test.php +++ b/tests/modules/LogStats_Db.test.php @@ -1,37 +1,37 @@ -<?php
-if(!defined("PATH_TEST_TO_ROOT")) {
- define('PATH_TEST_TO_ROOT', '..');
-}
-if(!defined('CONFIG_TEST_INCLUDED'))
-{
- require_once PATH_TEST_TO_ROOT ."/../tests/config_test.php";
-}
-
-require 'LogStats/Db.php';
-//Zend_Loader::loadClass('Piwik_');
-
-class Test_Piwik_LogStats_Db extends UnitTestCase
-{
- function __construct( $title = '')
- {
- parent::__construct( $title );
- }
-
- public function setUp()
- {
- }
-
- public function tearDown()
- {
- }
-
-
- /**
- * test that the profiler is disabled (mandatory on a production server)
- */
- public function test_profilingDisabledProduction()
- {
- $this->assertTrue(Piwik_LogStats_Db::isProfilingEnabled() === false, 'PROFILER SHOULD BE DISABLED IN PRODUCTION!! See Piwik_LogStats_Db::$profiling');
- }
-}
-
+<?php +if(!defined("PATH_TEST_TO_ROOT")) { + define('PATH_TEST_TO_ROOT', '..'); +} +if(!defined('CONFIG_TEST_INCLUDED')) +{ + require_once PATH_TEST_TO_ROOT ."/../tests/config_test.php"; +} + +require 'LogStats/Db.php'; +//Zend_Loader::loadClass('Piwik_'); + +class Test_Piwik_LogStats_Db extends UnitTestCase +{ + function __construct( $title = '') + { + parent::__construct( $title ); + } + + public function setUp() + { + } + + public function tearDown() + { + } + + + /** + * test that the profiler is disabled (mandatory on a production server) + */ + public function test_profilingDisabledProduction() + { + $this->assertTrue(Piwik_LogStats_Db::isProfilingEnabled() === false, 'PROFILER SHOULD BE DISABLED IN PRODUCTION!! See Piwik_LogStats_Db::$profiling'); + } +} + diff --git a/tests/modules/PHP_Related.test.php b/tests/modules/PHP_Related.test.php index 264bf84dd2..a37adeb5a3 100644 --- a/tests/modules/PHP_Related.test.php +++ b/tests/modules/PHP_Related.test.php @@ -38,9 +38,9 @@ class Test_PHP_Related extends UnitTestCase $this->assertEqual($elem1, 'key'); $this->assertEqual($elem2, 'elem2'); } - function test_TMP()
- {
- echo md5('root'.md5('nintendo'));
+ function test_TMP() + { + echo md5('root'.md5('nintendo')); } public function testStringEqualszero() @@ -49,7 +49,7 @@ class Test_PHP_Related extends UnitTestCase // it might seem strange. This was the reason of a bug I searched 1 hour for!! $this->assertTrue( $columnToSort == 0); - }
+ } public function testMergeArray() { @@ -263,42 +263,42 @@ class Test_PHP_Related extends UnitTestCase $size = round($size/1024/1024,3); //echo "<br>size compressed string = ". $size."mb"; //echo "<br>after compression all sub arrays = ". $timer; - }
-
- function test_functionReturnNothing()
- {
- function givemenothing()
- {
- $a = 4;
- }
-
- $return = givemenothing();
-
- $this->assertFalse(isset($return));
- $this->assertTrue(empty($return));
- $this->assertTrue(!is_int($return));
- $this->assertTrue(!is_string($return));
- $this->assertTrue(!is_bool($return));
} -
+ + function test_functionReturnNothing() + { + function givemenothing() + { + $a = 4; + } + + $return = givemenothing(); + + $this->assertFalse(isset($return)); + $this->assertTrue(empty($return)); + $this->assertTrue(!is_int($return)); + $this->assertTrue(!is_string($return)); + $this->assertTrue(!is_bool($return)); + } + +} + + +class test_staticAttr +{ + static public $a = 'testa'; + public $b = 'testb'; } -
-class test_staticAttr
-{
- static public $a = 'testa';
- public $b = 'testb';
-}
-
-class test_magicMethodStaticAttr
-{
- static $test = "test";
-
- function __get($name)
- {
- print("reading static attr ; __get called");
- return 1;
- }
+class test_magicMethodStaticAttr +{ + static $test = "test"; + + function __get($name) + { + print("reading static attr ; __get called"); + return 1; + } } diff --git a/tests/modules/Period.test.php b/tests/modules/Period.test.php index 85d67026f7..ba13fe3bc1 100644 --- a/tests/modules/Period.test.php +++ b/tests/modules/Period.test.php @@ -26,34 +26,34 @@ class Test_Piwik_Period extends UnitTestCase { // echo $this->timer . "<br> "; } -
- public function test_getId()
- {
- $period = new Piwik_Period_Day( Piwik_Date::today() );
- $this->assertTrue( $period->getId() !== 0 );
- $period = new Piwik_Period_Week( Piwik_Date::today() );
- $this->assertTrue( $period->getId() !== 0 );
- $period = new Piwik_Period_Month( Piwik_Date::today() );
- $this->assertTrue( $period->getId() !== 0 );
- $period = new Piwik_Period_Year( Piwik_Date::today() );
- $this->assertTrue( $period->getId() !== 0 );
- }
-
- public function test_getLabel()
- {
- $period = new Piwik_Period_Day( Piwik_Date::today() );
- $label = $period->getLabel();
- $this->assertTrue( is_string($label) && !empty($label));
- $period = new Piwik_Period_Week( Piwik_Date::today() );
- $label = $period->getLabel();
- $this->assertTrue( is_string($label) && !empty($label));
- $period = new Piwik_Period_Month( Piwik_Date::today() );
- $label = $period->getLabel();
- $this->assertTrue( is_string($label) && !empty($label));
- $period = new Piwik_Period_Year( Piwik_Date::today() );
- $label = $period->getLabel();
- $this->assertTrue( is_string($label) && !empty($label));
- }
+ + public function test_getId() + { + $period = new Piwik_Period_Day( Piwik_Date::today() ); + $this->assertTrue( $period->getId() !== 0 ); + $period = new Piwik_Period_Week( Piwik_Date::today() ); + $this->assertTrue( $period->getId() !== 0 ); + $period = new Piwik_Period_Month( Piwik_Date::today() ); + $this->assertTrue( $period->getId() !== 0 ); + $period = new Piwik_Period_Year( Piwik_Date::today() ); + $this->assertTrue( $period->getId() !== 0 ); + } + + public function test_getLabel() + { + $period = new Piwik_Period_Day( Piwik_Date::today() ); + $label = $period->getLabel(); + $this->assertTrue( is_string($label) && !empty($label)); + $period = new Piwik_Period_Week( Piwik_Date::today() ); + $label = $period->getLabel(); + $this->assertTrue( is_string($label) && !empty($label)); + $period = new Piwik_Period_Month( Piwik_Date::today() ); + $label = $period->getLabel(); + $this->assertTrue( is_string($label) && !empty($label)); + $period = new Piwik_Period_Year( Piwik_Date::today() ); + $label = $period->getLabel(); + $this->assertTrue( is_string($label) && !empty($label)); + } /** * Testing Period_Day @@ -98,97 +98,97 @@ class Test_Piwik_Period extends UnitTestCase $this->assertEqual( $period->getSubperiods(), array()); $this->assertEqual( $period->getNumberOfSubperiods(), 0); } -
- // test date that doesn't exist, should return the corresponding correct date
- function test_day_getDateStart1()
- {
- // create the period
- $period = new Piwik_Period_Day( new Piwik_Date("2007-02-31"));
-
- // start date
- $startDate = $period->getDateStart();
-
- // expected string
- $this->assertEqual( $startDate->toString(), "2007-03-03");
-
- // check that for a day, getDateStart = getStartEnd
- $this->assertEqual($startDate, $period->getDateEnd() );
- }
-
- // test normal date
- function test_day_getDateStart2()
- {
- // create the period
- $period = new Piwik_Period_Day( new Piwik_Date("2007-01-03"));
-
- // start date
- $startDate = $period->getDateStart();
-
- // expected string
- $this->assertEqual( $startDate->toString(), "2007-01-03");
-
- // check that for a day, getDateStart = getStartEnd
- $this->assertEqual($startDate, $period->getDateEnd() );
- }
-
- // test last day of year
- function test_day_getDateStart3()
- {
- // create the period
- $period = new Piwik_Period_Day( new Piwik_Date("2007-12-31"));
-
- // start date
- $startDate = $period->getDateStart();
-
- // expected string
- $this->assertEqual( $startDate->toString(), "2007-12-31");
-
- // check that for a day, getDateStart = getStartEnd
- $this->assertEqual($startDate, $period->getDateEnd() );
- }
-
-
- // test date that doesn't exist, should return the corresponding correct date
- function test_day_getDateEnd1()
- {
- // create the period
- $period = new Piwik_Period_Day( new Piwik_Date("2007-02-31"));
-
- // end date
- $endDate = $period->getDateEnd();
-
- // expected string
- $this->assertEqual( $endDate->toString(), "2007-03-03");
-
- }
-
- // test normal date
- function test_day_getDateEnd2()
- {
- // create the period
- $period = new Piwik_Period_Day( new Piwik_Date("2007-04-15"));
-
- // end date
- $endDate = $period->getDateEnd();
-
- // expected string
- $this->assertEqual( $endDate->toString(), "2007-04-15");
- }
-
- // test last day of year
- function test_day_getDateEnd3()
- {
- // create the period
- $period = new Piwik_Period_Day( new Piwik_Date("2007-12-31"));
-
- // end date
- $endDate = $period->getDateEnd();
-
- // expected string
- $this->assertEqual( $endDate->toString(), "2007-12-31");
- }
-
- // test date that doesn't exist, should return the corresponding correct date
+ + // test date that doesn't exist, should return the corresponding correct date + function test_day_getDateStart1() + { + // create the period + $period = new Piwik_Period_Day( new Piwik_Date("2007-02-31")); + + // start date + $startDate = $period->getDateStart(); + + // expected string + $this->assertEqual( $startDate->toString(), "2007-03-03"); + + // check that for a day, getDateStart = getStartEnd + $this->assertEqual($startDate, $period->getDateEnd() ); + } + + // test normal date + function test_day_getDateStart2() + { + // create the period + $period = new Piwik_Period_Day( new Piwik_Date("2007-01-03")); + + // start date + $startDate = $period->getDateStart(); + + // expected string + $this->assertEqual( $startDate->toString(), "2007-01-03"); + + // check that for a day, getDateStart = getStartEnd + $this->assertEqual($startDate, $period->getDateEnd() ); + } + + // test last day of year + function test_day_getDateStart3() + { + // create the period + $period = new Piwik_Period_Day( new Piwik_Date("2007-12-31")); + + // start date + $startDate = $period->getDateStart(); + + // expected string + $this->assertEqual( $startDate->toString(), "2007-12-31"); + + // check that for a day, getDateStart = getStartEnd + $this->assertEqual($startDate, $period->getDateEnd() ); + } + + + // test date that doesn't exist, should return the corresponding correct date + function test_day_getDateEnd1() + { + // create the period + $period = new Piwik_Period_Day( new Piwik_Date("2007-02-31")); + + // end date + $endDate = $period->getDateEnd(); + + // expected string + $this->assertEqual( $endDate->toString(), "2007-03-03"); + + } + + // test normal date + function test_day_getDateEnd2() + { + // create the period + $period = new Piwik_Period_Day( new Piwik_Date("2007-04-15")); + + // end date + $endDate = $period->getDateEnd(); + + // expected string + $this->assertEqual( $endDate->toString(), "2007-04-15"); + } + + // test last day of year + function test_day_getDateEnd3() + { + // create the period + $period = new Piwik_Period_Day( new Piwik_Date("2007-12-31")); + + // end date + $endDate = $period->getDateEnd(); + + // expected string + $this->assertEqual( $endDate->toString(), "2007-12-31"); + } + + // test date that doesn't exist, should return the corresponding correct date /** * Testing Period_Month diff --git a/tests/modules/Piwik.test.php b/tests/modules/Piwik.test.php index f4c94383d7..864fa18d97 100644 --- a/tests/modules/Piwik.test.php +++ b/tests/modules/Piwik.test.php @@ -48,17 +48,17 @@ class Test_Piwik extends UnitTestCase { $this->assertFalse(Piwik::isNumeric($toTest), $toTest." valid but shouldn't!"); } - }
-
- public function test_secureDiv()
- {
- $this->assertTrue( Piwik::secureDiv( 9,3 ) === 3 );
- $this->assertTrue( Piwik::secureDiv( 9,0 ) === 0 );
- $this->assertTrue( Piwik::secureDiv( 10,1 ) === 10 );
- $this->assertTrue( Piwik::secureDiv( 10.0, 1.0 ) === 10.0 );
- $this->assertTrue( Piwik::secureDiv( 11.0, 2 ) === 5.5 );
- $this->assertTrue( Piwik::secureDiv( 11.0, 'a' ) === 0 );
-
+ } + + public function test_secureDiv() + { + $this->assertTrue( Piwik::secureDiv( 9,3 ) === 3 ); + $this->assertTrue( Piwik::secureDiv( 9,0 ) === 0 ); + $this->assertTrue( Piwik::secureDiv( 10,1 ) === 10 ); + $this->assertTrue( Piwik::secureDiv( 10.0, 1.0 ) === 10.0 ); + $this->assertTrue( Piwik::secureDiv( 11.0, 2 ) === 5.5 ); + $this->assertTrue( Piwik::secureDiv( 11.0, 'a' ) === 0 ); + } } diff --git a/tests/modules/SitesManager.test.php b/tests/modules/SitesManager.test.php index cd2722c1bc..70ca724790 100755 --- a/tests/modules/SitesManager.test.php +++ b/tests/modules/SitesManager.test.php @@ -1,10 +1,10 @@ <?php -if(!defined("PATH_TEST_TO_ROOT")) {
- define('PATH_TEST_TO_ROOT', getcwd().'/../../');
-}
-if(!defined('CONFIG_TEST_INCLUDED'))
-{
- require_once PATH_TEST_TO_ROOT."tests/config_test.php";
+if(!defined("PATH_TEST_TO_ROOT")) { + define('PATH_TEST_TO_ROOT', getcwd().'/../../'); +} +if(!defined('CONFIG_TEST_INCLUDED')) +{ + require_once PATH_TEST_TO_ROOT."tests/config_test.php"; } require_once "Database.test.php"; diff --git a/tests/modules/TablePartitioning.test.php b/tests/modules/TablePartitioning.test.php index e512ba991e..43027cb8a8 100755 --- a/tests/modules/TablePartitioning.test.php +++ b/tests/modules/TablePartitioning.test.php @@ -48,7 +48,7 @@ class Test_Piwik_TablePartitioning extends Test_Database $p->setTimestamp( $timestamp ); - $allTablesInstalled = Piwik::getTablesInstalled($forceReload = true);
+ $allTablesInstalled = Piwik::getTablesInstalled($forceReload = true); $this->assertTrue( in_array($tablename, $allTablesInstalled), "$tablename !==".var_export($allTablesInstalled,true)); $this->assertTrue( $tablename, $p->getTableName()); diff --git a/tests/modules/UsersManager.test.php b/tests/modules/UsersManager.test.php index 148617feee..a635ee5d54 100644 --- a/tests/modules/UsersManager.test.php +++ b/tests/modules/UsersManager.test.php @@ -1,11 +1,11 @@ <?php -if(!defined("PATH_TEST_TO_ROOT")) {
- define('PATH_TEST_TO_ROOT', getcwd().'/../../');
-}
-if(!defined('CONFIG_TEST_INCLUDED'))
-{
- require_once PATH_TEST_TO_ROOT."tests/config_test.php";
-}
+if(!defined("PATH_TEST_TO_ROOT")) { + define('PATH_TEST_TO_ROOT', getcwd().'/../../'); +} +if(!defined('CONFIG_TEST_INCLUDED')) +{ + require_once PATH_TEST_TO_ROOT."tests/config_test.php"; +} require_once "Database.test.php"; @@ -31,58 +31,58 @@ class Test_Piwik_UsersManager extends Test_Database FakeAccess::$superUser = true; Zend_Registry::set('access', $pseudoMockAccess); - }
-
- private function _checkUserHasNotChanged($user, $newPassword, $newEmail = null, $newAlias= null)
- {
- if(is_null($newEmail))
- {
- $newEmail = $user['email'];
- }
- if(is_null($newAlias))
- {
- $newAlias = $user['alias'];
- }
- $userAfter = Piwik_UsersManager_API::getUser($user["login"]);
- unset($userAfter['date_registered']);
-
- // we now compute what the token auth should be, it should always be a hash of the login and the current password
- // if the password has changed then the token_auth has changed!
- $user['token_auth']= Piwik_UsersManager_API::getTokenAuth($user["login"], md5($newPassword) );
-
- $user['password']=md5($newPassword);
- $user['email']=$newEmail;
- $user['alias']=$newAlias;
- $this->assertEqual($user,$userAfter);
- }
-
- /**
- * bad password => exception
- */
- function test_updateUser_badpasswd()
- {
- $login="login";
- $user = array('login'=>$login,
- 'password'=>"geqgeagae",
- 'email'=>"test@test.com",
- 'alias'=>"alias");
-
- Piwik_UsersManager_API::addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] );
-
-
- try {
- Piwik_UsersManager_API::updateUser( $login, "pas");
- }
- catch (Exception $expected) {
- $this->assertPattern("(password)", $expected->getMessage());
-
- $this->_checkUserHasNotChanged($user,$user['password']);
- return;
- }
- $this->fail("Exception not raised.");
-
- }
-//} class test{
+ } + + private function _checkUserHasNotChanged($user, $newPassword, $newEmail = null, $newAlias= null) + { + if(is_null($newEmail)) + { + $newEmail = $user['email']; + } + if(is_null($newAlias)) + { + $newAlias = $user['alias']; + } + $userAfter = Piwik_UsersManager_API::getUser($user["login"]); + unset($userAfter['date_registered']); + + // we now compute what the token auth should be, it should always be a hash of the login and the current password + // if the password has changed then the token_auth has changed! + $user['token_auth']= Piwik_UsersManager_API::getTokenAuth($user["login"], md5($newPassword) ); + + $user['password']=md5($newPassword); + $user['email']=$newEmail; + $user['alias']=$newAlias; + $this->assertEqual($user,$userAfter); + } + + /** + * bad password => exception + */ + function test_updateUser_badpasswd() + { + $login="login"; + $user = array('login'=>$login, + 'password'=>"geqgeagae", + 'email'=>"test@test.com", + 'alias'=>"alias"); + + Piwik_UsersManager_API::addUser($user['login'],$user['password'] ,$user['email'] ,$user['alias'] ); + + + try { + Piwik_UsersManager_API::updateUser( $login, "pas"); + } + catch (Exception $expected) { + $this->assertPattern("(password)", $expected->getMessage()); + + $this->_checkUserHasNotChanged($user,$user['password']); + return; + } + $this->fail("Exception not raised."); + + } +//} class test{ /** * wrong login / integer => exception @@ -499,23 +499,23 @@ class Test_Piwik_UsersManager extends Test_Database ); } -
- /**
- * normal case
- */
- function test_getUsersLogin()
- {
-
- Piwik_UsersManager_API::addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
- Piwik_UsersManager_API::addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
-
- $logins = Piwik_UsersManager_API::getUsersLogin();
-
- $this->assertEqual($logins,
- array( "gegg4564eqgeqag", "geggeqge632ge56a4qag", "geggeqgeqagqegg")
- );
- }
+ + /** + * normal case + */ + function test_getUsersLogin() + { + + Piwik_UsersManager_API::addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias"); + Piwik_UsersManager_API::addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias"); + Piwik_UsersManager_API::addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com"); + + $logins = Piwik_UsersManager_API::getUsersLogin(); + + $this->assertEqual($logins, + array( "gegg4564eqgeqag", "geggeqge632ge56a4qag", "geggeqgeqagqegg") + ); + } /** |