Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
56d2c6be
Commit
56d2c6be
authored
12 years ago
by
Chris Leppanen
Browse files
Options
Downloads
Patches
Plain Diff
Method for downloading and extracting the simplepie library during tests.
parent
fa92b44a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/feeds.test
+56
-0
56 additions, 0 deletions
tests/feeds.test
with
56 additions
and
0 deletions
tests/feeds.test
+
56
−
0
View file @
56d2c6be
...
@@ -433,6 +433,62 @@ class FeedsWebTestCase extends DrupalWebTestCase {
...
@@ -433,6 +433,62 @@ class FeedsWebTestCase extends DrupalWebTestCase {
}
}
}
}
}
}
/**
* Download and extract SimplePIE.
*
* Sets the 'feeds_simplepie_library_dir' variable to the directory where
* SimplePie is downloaded.
*
* @param $version
* The SimplePie version number to download and extract.
*/
function
downloadExtractSimplePie
(
$version
)
{
$url
=
"https://github.com/simplepie/simplepie/tarball/
$version
"
;
$filename
=
"SimplePIE-
$version
.tar.gz"
;
// Avoid downloading the file dozens of times
$library_dir
=
$this
->
originalFileDirectory
.
'/simpletest/feeds'
;
$simplepie_library_dir
=
$library_dir
.
'/simplepie'
;
if
(
!
file_exists
(
$library_dir
))
{
mkdir
(
$library_dir
,
'0777'
,
TRUE
);
}
// Local archive name.
$local_archive
=
$library_dir
.
'/'
.
$filename
;
// Begin single threaded code.
if
(
function_exists
(
'sem_get'
))
{
$semaphore
=
sem_get
(
ftok
(
__FILE__
,
1
));
sem_acquire
(
$semaphore
);
}
// Download and extact the archive, but only in one thread.
if
(
!
file_exists
(
$local_archive
))
{
$local_archive
=
system_retrieve_file
(
$url
,
$local_archive
,
FALSE
,
FILE_EXISTS_REPLACE
);
}
if
(
!
file_exists
(
$library_dir
))
{
// Extract the files.
$archiver
=
archiver_get_archiver
(
$local_archive
);
$archiver
->
extract
(
$library_dir
);
$dirs
=
glob
(
$library_dir
.
'/simplepie*'
,
GLOB_ONLYDIR
);
$dir
=
reset
(
$dirs
);
rename
(
$dir
,
$simplepie_library_dir
);
}
if
(
function_exists
(
'sem_get'
))
{
sem_release
(
$semaphore
);
}
// End single threaded code.
// Verify that files were successfully extracted.
$this
->
assertTrue
(
file_exists
(
$simplepie_library_dir
.
'/simplepie.inc'
),
t
(
'simpletest.inc found in @library_dir.'
,
array
(
'library_dir'
=>
$library_dir
)));
// Set the simpletest library directory.
variable_set
(
'feeds_library_dir'
,
$library_dir
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment