Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #18612: When surveys are copied without copying resources…
… links are not handled (#3009) * Fixed issue #18612: When surveys are copied without copying resources, links are not handled * Fixed issue #18612: When surveys are copied without copying resources links are not handled Unit tests for checkOldLinks function added. --------- Co-authored-by: lapiudevgit <devgit@lapiu.biz>
- Loading branch information
1 parent
c4d672c
commit e979de0
Showing
3 changed files
with
232 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
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,60 @@ | ||
<?php | ||
|
||
namespace ls\tests; | ||
|
||
/** | ||
* Tests for the checkOldLinks function. | ||
*/ | ||
|
||
class CheckOldLinksTest extends TestBaseClass | ||
{ | ||
public static function setupBeforeClass(): void | ||
{ | ||
parent::setupBeforeClass(); | ||
\Yii::import('application.helpers.common_helper', true); | ||
} | ||
|
||
public function testEmptyLink() | ||
{ | ||
$oldLinks = checkOldLinks('survey', '111111', ''); | ||
$this->assertFalse($oldLinks, 'The link should be empty.'); | ||
} | ||
|
||
public function testUnknownType() | ||
{ | ||
$oldLinks = checkOldLinks('encuesta', '111111', ''); | ||
$this->assertFalse($oldLinks, 'Link type is not survey or label.'); | ||
} | ||
|
||
public function testNoSurveyOldLinks() | ||
{ | ||
$newLink = 'http://' . getenv('DOMAIN') . '/upload/surveys/222222/'; | ||
$oldLinks = checkOldLinks('survey', '111111', $newLink); | ||
|
||
$this->assertFalse((bool)$oldLinks, 'The url ' . $newLink . ' is an old link.'); | ||
} | ||
|
||
public function testSurveyOldLinks() | ||
{ | ||
$newLink = 'http://' . getenv('DOMAIN') . '/upload/surveys/2222/'; | ||
$oldLinks = checkOldLinks('survey', '2222', $newLink); | ||
|
||
$this->assertTrue((bool)$oldLinks, 'The url ' . $newLink . ' is not an old link.'); | ||
} | ||
|
||
public function testNoLabelOldLinks() | ||
{ | ||
$newLink = 'http://' . getenv('DOMAIN') . '/upload/labels/222222/'; | ||
$oldLinks = checkOldLinks('label', '111111', $newLink); | ||
|
||
$this->assertFalse((bool)$oldLinks, 'The url ' . $newLink . ' is an old link.'); | ||
} | ||
|
||
public function testLabelOldLinks() | ||
{ | ||
$newLink = 'http://' . getenv('DOMAIN') . '/upload/labels/2222/'; | ||
$oldLinks = checkOldLinks('label', '2222', $newLink); | ||
|
||
$this->assertTrue((bool)$oldLinks, 'The url ' . $newLink . ' is not an old link.'); | ||
} | ||
} |