Esempio n. 1
0
 public function testEndsWith()
 {
     $this->assertTrue(\asm\utils\Utils::endsWith("HELLO", "LLO"));
     $this->assertTrue(\asm\utils\Utils::endsWith("HELLO", ""));
     $this->assertTrue(\asm\utils\Utils::endsWith("HELLO", "LO"));
     $this->assertTrue(\asm\utils\Utils::endsWith("HELLO", "O"));
     $this->assertTrue(\asm\utils\Utils::endsWith("HELLO", "ELLO"));
     $this->assertTrue(\asm\utils\Utils::endsWith("HELLO", "HELLO"));
     $this->assertFalse(\asm\utils\Utils::endsWith("HELLO", "hello"));
     $this->assertFalse(\asm\utils\Utils::endsWith("HELLO", "lo"));
     $this->assertFalse(\asm\utils\Utils::endsWith("HELLO", "HESTR"));
     $this->assertFalse(\asm\utils\Utils::endsWith("HELLO", "H"));
     $this->assertFalse(\asm\utils\Utils::endsWith("HELLO", "ALLO"));
     $this->assertFalse(\asm\utils\Utils::endsWith("HELLO", "Some long string"));
 }
Esempio n. 2
0
 /**
  * Attempts to find an XML and an XSL filename in the given folder and adds an error if it cannot find them.
  * @param $fromWhere string directory from where to load the files
  * @param $xmlFile string The found XML filename.
  * @param $xslFile string The found XSL filename.
  */
 private function loadFiles($fromWhere, &$xmlFile, &$xslFile)
 {
     $xmlFile = false;
     $xslFile = false;
     $files = \asm\utils\Filesystem::getFiles($fromWhere);
     foreach ($files as $file) {
         if (Utils::endsWith(strtolower($file), ".xml")) {
             if ($xmlFile === false) {
                 $xmlFile = \asm\utils\Filesystem::combinePaths($fromWhere, $file);
             } else {
                 $this->addError("There are two or more .xml files in your submission. There must only be one.");
             }
         }
         if (Utils::endsWith(strtolower($file), ".xsl")) {
             if ($xslFile === false) {
                 $xslFile = \asm\utils\Filesystem::combinePaths($fromWhere, $file);
             } else {
                 $this->addError("There are two or more .xsl files in your submission. There must only be one.");
             }
         }
     }
     if ($xmlFile === false) {
         $this->addError("Your submission must contain an XML file ending with '.xml'.");
     }
     if ($xslFile === false) {
         $this->addError("Your submission must contain an XSL file ending with '.xsl'.");
     }
 }