示例#1
0
 public function setUp()
 {
     $package_factory = new FRSPackageFactoryMock();
     $release_factory = new FRSReleaseFactory();
     $file_factory = new FRSXMLImporterTest_FRSFileFactory();
     $this->package_dao = mock('FRSPackageDao');
     $package_factory->dao = $this->package_dao;
     FRSPackageFactory::setInstance($package_factory);
     $this->permissions_manager = mock('PermissionsManager');
     PermissionsManager::setInstance($this->permissions_manager);
     $this->release_dao = mock('FRSReleaseDao');
     $release_factory->dao = $this->release_dao;
     $release_factory->package_factory = $package_factory;
     $release_factory->file_factory = $file_factory;
     FRSReleaseFactory::setInstance($release_factory);
     $this->file_dao = mock('FRSFileDao');
     $file_factory->dao = $this->file_dao;
     $file_factory->release_factory = $release_factory;
     $this->processor_dao = mock('FRSProcessorDao');
     $this->filetype_dao = mock('FRSFileTypeDao');
     $this->user_finder = mock('User\\XML\\Import\\IFindUserFromXMLReference');
     $this->user_manager = mock('UserManager');
     UserManager::setInstance($this->user_manager);
     $this->ugroup_dao = mock("UGroupDao");
     stub($this->ugroup_dao)->searchByGroupIdAndName()->returns(new DataAccessResultEmpty());
     $this->frs_importer = new FRSXMLImporter(mock('Logger'), new XML_RNGValidator(), $package_factory, $release_factory, $file_factory, $this->user_finder, new UGroupManager($this->ugroup_dao), $this->processor_dao, $this->filetype_dao);
     EventManager::setInstance(mock('EventManager'));
     $GLOBALS['Language'] = mock('BaseLanguage');
     if (isset($GLOBALS['ftp_incoming_dir'])) {
         $this->old_ftp_incoming_dir = $GLOBALS['ftp_incoming_dir'];
     }
     if (isset($GLOBALS['old_ftp_frs_dir_prefix'])) {
         $this->old_ftp_frs_dir_prefix = $GLOBALS['ftp_frs_dir_prefix'];
     }
     $GLOBALS['ftp_incoming_dir'] = parent::getTmpDir();
     $GLOBALS['ftp_frs_dir_prefix'] = parent::getTmpDir();
 }
 private function import($xml)
 {
     return $this->importer->import($this->project, mock('PFUSer'), $xml, parent::getTmpDir());
 }
示例#3
0
    public function itShouldImportSvnAccessFile()
    {
        $project = new Project(array('group_id' => 123, 'unix_group_name' => 'test_project'));
        $access_file = "[groups]\nmembers = usernameTOTO123\n\n\n[/]\n* = r\n@members = rw\n";
        $xml_document = <<<XML
            <project>
                <svn>
                    <access-file>{$access_file}</access-file>
                </svn>
            </project>
XML;
        $this->importer->import($project, new SimpleXMLElement($xml_document), parent::getTmpDir());
        $dao = $this->svn_accessfile_dao;
        $dao->expectCallCount('saveNewAccessFileVersionInProject', 1);
        $dao->expectAt(0, 'saveNewAccessFileVersionInProject', array(123, $access_file));
        $svnroot = $project->getSVNRootPath();
        $accessfile = "{$svnroot}/.SVNAccessFile";
        $found = strstr(file_get_contents($accessfile), "TOTO123") !== false;
        $this->assertTrue($found);
    }
示例#4
0
    public function itShouldImportNotifications()
    {
        $project = new Project(array('group_id' => 123, 'unix_group_name' => 'test_project'));
        $xml_document = <<<XML
            <project>
                <svn>
                    <notification path="/trunk" emails="test1@domain1, test2@domain2"/>
                    <notification path="/tags" emails="tags@domain3"/>
                </svn>
            </project>
XML;
        $res = $this->importer->import($project, new SimpleXMLElement($xml_document), parent::getTmpDir());
        $this->assertTrue($res);
        $dao = $this->svn_notification_dao;
        $dao->expectAt(0, 'setSvnMailingList', array(123, "test1@domain1, test2@domain2", "/trunk"));
        $dao->expectAt(1, 'setSvnMailingList', array(123, "tags@domain3", "/tags"));
        $dao->expectCallCount('setSvnMailingList', 2);
    }