3 require_once
'lib/bagit_fetch.php';
4 require_once
'lib/bagit_utils.php';
13 $this->tmpdir = tmpdir();
17 "{$this->tmpdir}/fetch.txt",
18 "http://www.google.com - data/google/index.html\n" .
19 "http://www.yahoo.com - data/yahoo/index.html\n"
22 $this->fetch =
new BagItFetch(
"{$this->tmpdir}/fetch.txt");
27 rrmdir($this->tmpdir);
33 "{$this->tmpdir}/fetch.txt",
34 $this->fetch->fileName
40 $data = $this->fetch->data;
42 $this->assertEquals(2, count($data));
43 $this->assertEquals(
"http://www.google.com", $data[0][
'url']);
44 $this->assertEquals(
"http://www.yahoo.com", $data[1][
'url']);
50 "{$this->tmpdir}/fetch.txt",
51 "http://www.scholarslab.org/ - data/scholarslab/index.html"
57 array_key_exists(
'data/google/index.html', $this->fetch->data)
60 array_key_exists(
'data/yahoo/index.html', $this->fetch->data)
63 'data/scholarslab/index.html',
64 $this->fetch->data[0][
'filename']
72 array(
'url' =>
'http://www.scholarslab.org/',
'length' =>
'-',
'filename' =>
'data/scholarslab/index.html')
74 $this->fetch->write();
76 "http://www.google.com - data/google/index.html\n" .
77 "http://www.yahoo.com - data/yahoo/index.html\n" .
78 "http://www.scholarslab.org/ - data/scholarslab/index.html\n",
79 file_get_contents(
"{$this->tmpdir}/fetch.txt")
85 $data = $this->fetch->getData();
87 $this->assertEquals(2, count($data));
88 $this->assertEquals(
"http://www.google.com", $data[0][
'url']);
89 $this->assertEquals(
"http://www.yahoo.com", $data[1][
'url']);
96 $this->assertFalse(is_file(
"$tmp/data/google/index.html"));
97 $this->assertFalse(is_file(
"$tmp/data/yahoo/index.html"));
100 $this->fetch->download();
102 $this->assertFileExists(
"$tmp/data/google/index.html");
103 $this->assertFileExists(
"$tmp/data/yahoo/index.html");
108 $this->assertEquals(2, count($this->fetch->data));
111 'http://www.scholarslab.org/',
112 'data/scholarslab/index.html'
115 $this->assertEquals(3, count($this->fetch->data));
117 'data/scholarslab/index.html',
118 $this->fetch->data[2][
'filename']
122 "http://www.google.com - data/google/index.html\n" .
123 "http://www.yahoo.com - data/yahoo/index.html\n" .
124 "http://www.scholarslab.org/ - data/scholarslab/index.html\n",
125 file_get_contents(
"{$this->tmpdir}/fetch.txt")
131 $this->assertEquals(2, count($this->fetch->data));
133 $this->fetch->clear();
135 $this->assertEquals(0, count($this->fetch->data));
137 array_key_exists(
'data/google/index.html', $this->fetch->data)
140 array_key_exists(
'data/yahoo/index.html', $this->fetch->data)
146 $this->fetch->clear();
147 $this->fetch->write();
148 $this->assertFileNotExists(
"{$this->tmpdir}/fetch.txt");
153 $bagdir =
"{$this->tmpdir}/_bag";
155 $bag =
new BagIt($bagdir);
156 $this->assertFileNotExists(
"$bagdir/fetch.txt");
159 $this->assertFileNotExists(
"$bagdir/fetch.txt");