-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some controller tests for import and update
Currently these just validate expected errors caused by limitations in the test stack.
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* @package TeiEditions | ||
* | ||
* @copyright Copyright 2021 King's College London Department of Digital Humanities | ||
*/ | ||
|
||
|
||
class AdminController_FilesTest extends TeiEditions_Case_Default | ||
{ | ||
public function setUpLegacy() | ||
{ | ||
parent::setUpLegacy(); | ||
|
||
$importer = new TeiEditions_Helpers_DataImporter(get_db()); | ||
|
||
$created = 0; | ||
$updated = 0; | ||
$onDone = function() { }; | ||
$importer->importData( | ||
__DIR__ . '/../resources/enhance-tei.xml', | ||
'text/xml', | ||
false, | ||
false, | ||
$created, | ||
$updated, | ||
function(){} | ||
); | ||
$this->assertEquals(1, $created); | ||
} | ||
|
||
public function testFilesImport() { | ||
// TODO: figure out how to test an upload...??? | ||
$this->request->setMethod('POST'); | ||
$this->dispatch('tei-editions/files/import'); | ||
|
||
// The form will error because we haven't provided a file | ||
$this->assertXpath("//div[@id='flash']/ul/li[@class='error']"); | ||
} | ||
|
||
public function testFilesUpdate() { | ||
// An empty items[] key should update all items... | ||
$this->request->setMethod('POST')->setPost(['create_exhibit' => 0]); | ||
$this->dispatch('tei-editions/files/update'); | ||
|
||
// NB: as with the Data Import test I haven't figured out how to | ||
// make updating work in the test environment because the files are | ||
// not available at their web URL. Therefore, for now asserting that | ||
// this method errors as expected at least ensures it doesn't crash. | ||
$this->assertXpath("//div[@id='flash']/ul/li[@class='error']"); | ||
} | ||
} |