-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix validate command for table name prefixes
- Loading branch information
Showing
6 changed files
with
116 additions
and
3 deletions.
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
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,41 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<XMLDB PATH="local/travis/db" VERSION="2015071000" COMMENT="XMLDB file for Moodle local/travis" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd" | ||
> | ||
<TABLES> | ||
<TABLE NAME="local_travis_config" COMMENT="This is a config table."> | ||
<FIELDS> | ||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> | ||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/> | ||
<FIELD NAME="value" TYPE="text" NOTNULL="true" SEQUENCE="false"/> | ||
</FIELDS> | ||
<KEYS> | ||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> | ||
<KEY NAME="name" TYPE="unique" FIELDS="name"/> | ||
</KEYS> | ||
</TABLE> | ||
<TABLE NAME="config" COMMENT="This is a config table."> | ||
<FIELDS> | ||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> | ||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/> | ||
<FIELD NAME="value" TYPE="text" NOTNULL="true" SEQUENCE="false"/> | ||
</FIELDS> | ||
<KEYS> | ||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> | ||
<KEY NAME="name" TYPE="unique" FIELDS="name"/> | ||
</KEYS> | ||
</TABLE> | ||
<TABLE NAME="local_travis_config2" COMMENT="This is a config table."> | ||
<FIELDS> | ||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> | ||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/> | ||
<FIELD NAME="value" TYPE="text" NOTNULL="true" SEQUENCE="false"/> | ||
</FIELDS> | ||
<KEYS> | ||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> | ||
<KEY NAME="name" TYPE="unique" FIELDS="name"/> | ||
</KEYS> | ||
</TABLE> | ||
</TABLES> | ||
</XMLDB> |
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,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Moodle Plugin CI package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com) | ||
* License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace Moodlerooms\MoodlePluginCI\Tests\PluginValidate\Finder; | ||
|
||
use Moodlerooms\MoodlePluginCI\PluginValidate\Finder\FileTokens; | ||
use Moodlerooms\MoodlePluginCI\PluginValidate\Finder\TablePrefixFinder; | ||
|
||
class TablePrefixFinderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testFindTokens() | ||
{ | ||
$file = __DIR__.'/../../Fixture/moodle-local_travis/db/install.xml'; | ||
$fileTokens = FileTokens::create('db/install.xml')->mustHave('local_travis'); | ||
|
||
$finder = new TablePrefixFinder(); | ||
$finder->findTokens($file, $fileTokens); | ||
|
||
$this->assertTrue($fileTokens->hasFoundAllTokens()); | ||
} | ||
|
||
public function testFindTokensFail() | ||
{ | ||
$file = __DIR__.'/../../Fixture/bad-install.xml'; | ||
$fileTokens = FileTokens::create('db/install.xml')->mustHave('local_travis'); | ||
|
||
$finder = new TablePrefixFinder(); | ||
$finder->findTokens($file, $fileTokens); | ||
|
||
$this->assertFalse($fileTokens->hasFoundAllTokens()); | ||
} | ||
} |