Changeset 12558


Ignore:
Timestamp:
09/18/11 12:43:08 (20 months ago)
Author:
PaulHarvey
Message:

Item11135: wiring up the new store API - now the unit test infrastructure doesn't crash - next up, make some tests pass

Location:
branches/scratch/UnitTestContrib/test/unit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/scratch/UnitTestContrib/test/unit/FoswikiFnTestCase.pm

    r12483 r12558  
    109109    $this->{test_user_cuid} = 
    110110      $this->{session}->{users}->getCanonicalUserID( $this->{test_user_login} ); 
    111     $this->{test_topicObject} = Foswiki::Meta->new( 
    112         $this->{session},    $this->{test_web}, 
    113         $this->{test_topic}, "BLEEGLE\n" 
    114     ); 
     111 
     112    $this->{test_topicObject} = Foswiki::Store::create(address=>{web=>$this->{test_web}, topic=>$this->{test_topic}}); 
     113    $this->{test_topicObject}->text("BLEEGLE\n"); 
    115114    $this->{test_topicObject}->save(forcedate=>(time()+60)); 
    116115} 
  • branches/scratch/UnitTestContrib/test/unit/FoswikiTestCase.pm

    r12489 r12558  
    266266 
    267267    try { 
    268         my $webObject = Foswiki::Meta->new( $session, $web ); 
     268        my $webObject = Foswiki::Store->load( address=>{web=>$web} ); 
    269269        $webObject->removeFromStore(); 
    270270    } 
  • branches/scratch/UnitTestContrib/test/unit/FuncUsersTests.pm

    r12435 r12558  
    17621762} 
    17631763 
     1764sub verify_denyNonAdminReadOfAdminGroupTopic { 
     1765    my $this = shift; 
     1766 
     1767    return if ( $this->noUsersRegistered() ); 
     1768 
     1769    # Force a re-read 
     1770    $this->{session}->finish(); 
     1771    $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
     1772    $Foswiki::Plugins::SESSION = $this->{session}; 
     1773     
     1774    $this->assert( Foswiki::Func::addUserToGroup( 'UserB',    'AdminGroup', 1 ) ); 
     1775 
     1776    my $topicObject = 
     1777      Foswiki::Meta->new( $this->{session}, $this->{users_web}, 
     1778        'AdminGroup' ); 
     1779    $topicObject->load(); 
     1780    $topicObject->text($topicObject."\n\n   * Set ALLOWTOPICVIEW = AdminGroup\n\n"); 
     1781    $topicObject->save(); 
     1782     
     1783     
     1784    { 
     1785        $this->{session}->finish(); 
     1786        $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
     1787        $Foswiki::Plugins::SESSION = $this->{session}; 
     1788 
     1789        my $it = Foswiki::Func::eachGroupMember('AdminGroup'); 
     1790        my @list; 
     1791        while ( $it->hasNext() ) { 
     1792            my $g = $it->next(); 
     1793            push( @list, $g ); 
     1794        } 
     1795        #as the baseusermapper is always admin, they should always see the full list 
     1796        $this->assert_str_equals( "AdminUser,UserA,UserB", 
     1797            sort join( ',', @list ) ); 
     1798        $this->assert($this->{session}->isAdmin()); 
     1799    } 
     1800 
     1801    { 
     1802        # Force a re-read 
     1803        $this->{session}->finish(); 
     1804        $this->{session} = new Foswiki( 'UserB' ); 
     1805        $Foswiki::Plugins::SESSION = $this->{session}; 
     1806 
     1807        my $it = Foswiki::Func::eachGroupMember('AdminGroup'); 
     1808        my @list; 
     1809        while ( $it->hasNext() ) { 
     1810            my $g = $it->next(); 
     1811            push( @list, $g ); 
     1812        } 
     1813        $this->assert_str_equals( "AdminUser,UserA,UserB", 
     1814            sort join( ',', @list ) ); 
     1815        $this->assert($this->{session}->isAdmin()) 
     1816    } 
     1817 
     1818    { 
     1819        # Force a re-read 
     1820        $this->{session}->finish(); 
     1821        $this->{session} = new Foswiki( 'UserZ' ); 
     1822        $Foswiki::Plugins::SESSION = $this->{session}; 
     1823 
     1824        my $it = Foswiki::Func::eachGroupMember('AdminGroup'); 
     1825        my @list; 
     1826        while ( $it->hasNext() ) { 
     1827            my $g = $it->next(); 
     1828            push( @list, $g ); 
     1829        } 
     1830        $this->assert_str_equals( "AdminUser,UserA,UserB", 
     1831            sort join( ',', @list ) ); 
     1832        $this->assert(not $this->{session}->isAdmin()) 
     1833    } 
     1834} 
     1835 
     1836 
    176418371; 
  • branches/scratch/UnitTestContrib/test/unit/PrefsTests.pm

    r8245 r12558  
    4444        my $webObject = Foswiki::Meta->new( $this->{session}, $TWiki::cfg{SystemWebName} ); 
    4545        $webObject->populateNewWeb($original); 
    46         my $m = 
    47           Foswiki::Meta->load( $this->{session}, $original, 
    48             $TWiki::cfg{SitePrefsTopicName} ); 
    49         $m->saveAs( $TWiki::cfg{SystemWebName}, 
    50             $TWiki::cfg{SitePrefsTopicName} ); 
     46 
     47        my $orig_sitepref = Foswiki::Store::load(address=>{web=>$original, topic=>$Foswiki::cfg{SitePrefsTopicName}}); 
     48        my $m = Foswiki::Store::create(address=>{web=>$TWiki::cfg{SystemWebName}, topic=>$Foswiki::cfg{SitePrefsTopicName}}, data=>{_text=>$orig_sitepref->text()}); 
     49        $m->save(); 
    5150    } 
    5251    catch Foswiki::AccessControlException with { 
     
    8079    my $user = $fatwilly->{user}; 
    8180    $this->assert_not_null($user); 
    82     my $topicObject = Foswiki::Meta->load( $fatwilly, $web, $topic ); 
     81    my $topicObject = Foswiki::Store::load(address=>{web=>$web, topic=>$topic}); 
     82 
    8383    my $text = $topicObject->text() || ''; 
    8484    $text =~ s/^\s*\* $type $pref =.*$//gm; 
Note: See TracChangeset for help on using the changeset viewer.