diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..63870e5 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,86 @@ +name: 'Unit Tests' +on: + workflow_dispatch: + push: + branches: + - master + pull_request: +jobs: + Sqlite: + runs-on: ubuntu-latest + container: kanboard/tests:latest + steps: + - name: Checkout Kanboard repo + uses: actions/checkout@v2 + with: + repository: kanboard/kanboard + - name: Checkout Plugin repo + uses: actions/checkout@v2 + with: + path: plugins/Wiki + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + - name: Unit tests with Sqlite + run: ./vendor/bin/phpunit -c tests/units.sqlite.xml plugins/Wiki/Test/ + + Postgres: + runs-on: ubuntu-latest + container: kanboard/tests:latest + services: + postgres: + image: postgres:9.4 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - name: Checkout Kanboard repo + uses: actions/checkout@v2 + with: + repository: kanboard/kanboard + - name: Checkout Plugin repo + uses: actions/checkout@v2 + with: + path: plugins/Wiki + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + - name: Unit tests with Postgres + run: ./vendor/bin/phpunit -c tests/units.postgres.xml plugins/Wiki/Test/ + env: + DB_HOSTNAME: postgres + DB_PORT: ${{ job.services.postgres.ports[5432] }} + + MariaDB: + runs-on: ubuntu-latest + container: kanboard/tests:latest + services: + mariadb: + image: mariadb:latest + env: + MYSQL_ROOT_PASSWORD: secret + ports: + - 3306:3306 + steps: + - name: Checkout Kanboard repo + uses: actions/checkout@v2 + with: + repository: kanboard/kanboard + - name: Checkout Plugin repo + uses: actions/checkout@v2 + with: + path: plugins/Wiki + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + - name: Unit tests with MariaDB + run: ./vendor/bin/phpunit -c tests/units.mysql.xml plugins/Wiki/Test/ + env: + DB_HOSTNAME: mariadb + DB_PASSWORD: secret + DB_PORT: ${{ job.services.mariadb.ports[3306] }} \ No newline at end of file diff --git a/README.md b/README.md index b50002b..fa2b1d4 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Note that you can only restore **saved** editions. So you if you have the global - [] ordering - [] drop down to switch - [] drag to move, require css magic +- [] subpages and pagination - [x] fix wiki sidebar - use html template render properly to list wiki pages - still having difficulty getting template helper working, manually added for each page @@ -112,6 +113,7 @@ version=0.2.6 ``` To run a new build type `make`. NOTE: this only zips files in the last commit in the branch you are on. If you haven't commited your changes these won't be included in the zip. + * windows install make `choco install make` After testing create a new tag in github or via cli. `git tag -a 0.2.6 -m "Translations Updates"`. Then `git push origin --tags` Then upload the new **Wiki-version.zip** produced from `make`. Then do a pull request on https://github.com/kanboard/website for the plugins.json to update the plugin url. The `version` & `download` attributes are important to be correct. diff --git a/Test/Model/WikiPageTest.php b/Test/Model/WikiPageTest.php index c6ad56e..70f5e0a 100644 --- a/Test/Model/WikiPageTest.php +++ b/Test/Model/WikiPageTest.php @@ -4,12 +4,22 @@ use Kanboard\Core\Plugin\Loader; use Kanboard\Plugin\Wiki\Model\Wiki; +use Kanboard\Model\ProjectModel; +use Kanboard\Core\User\UserSession; +use Kanboard\Core\Security\AuthenticationManager; +use Kanboard\Auth\DatabaseAuth; class WikiPageTest extends Base { - public function setUp() + /** + * @var Plugin + */ + protected $plugin; + + protected function setUp(): void { parent::setUp(); + // $this->plugin = new Plugin($this->container); $plugin = new Loader($this->container); $plugin->scan(); @@ -17,52 +27,45 @@ public function setUp() public function testCreation() { - $wikimodel = new Wiki($this->container); - // $this->assertEquals(1, $wikimodel->createpage(1, "Security", "Some content", '2015-01-01')); - // $this->assertEquals(2, $wikimodel->createpage(1, "Conventions", 'More content')); - - // $editions = $wikimodel->getEditions(1); - // $this->assertEmpty($editions); + $projectModel = new ProjectModel($this->container); - // $values = [ - // 'title' => "Security", - // 'content' => "Some content", - // ]; + $this->assertEquals($projectModel->create(array('name' => 'UnitTest')), 1, 'Failed to create project'); - // $this->assertEquals(1, $wikimodel->createEdition($values, 1, 1)); + $project = $projectModel->getById(1); - // createpage - - // $rates = $hr->getAllByUser(0); - // $this->assertEmpty($rates); + $wikimodel = new Wiki($this->container); + // create wiki pages + $this->assertEquals($wikimodel->createpage($project['id'], "Security", "Some content", '2015-01-01'), 1, 'Failed to a create wiki page on project'); + $this->assertEquals($wikimodel->createpage($project['id'], "Conventions", 'More content'), 2, 'Failed to an additional create wiki page on project'); - // $editions = $wikimodel->getEditions(1); - // $this->assertNotEmpty($editions); - // $rates = $hr->getAllByUser(1); - // $this->assertNotEmpty($rates); - // $this->assertCount(1, $editions); + // grab editions for first wiki page + $editions = $wikimodel->getEditions(1); + $this->assertEmpty($editions); - // $this->assertEquals(42, $rates[0]['rate']); - // $this->assertEquals('Security', $editions[0]['title']); - // $this->assertEquals('Some content', $editions[0]['content']); + $values = [ + 'title' => "Security", + 'content' => "Some content", + ]; - // $this->assertEquals('2015-02-01', date('Y-m-d', $rates[0]['date_effective'])); + // create wiki page edition + + $authManager = new AuthenticationManager($this->container); + $authManager->register(new DatabaseAuth($this->container)); - // $this->assertEquals(32.4, $rates[1]['rate']); - // $this->assertEquals('EUR', $rates[1]['currency']); - // $this->assertEquals('2015-01-01', date('Y-m-d', $rates[1]['date_effective'])); + $_SESSION['user'] = array('id' => 1, 'username' => 'test', 'role' => 'app-admin'); - // $this->assertEquals(0, $hr->getCurrentRate(0)); - // $this->assertEquals(42, $hr->getCurrentRate(1)); + $this->assertTrue($this->container['userSession']->isLogged(), 'Failed to login'); - // $this->assertTrue($wikimodel->removepage(1)); - // $this->assertEquals(32.4, $hr->getCurrentRate(1)); + $this->userSession = new UserSession($this->container); + // result is not a consistent 1. is this true or id for new edition? + $createEditionResult = $wikimodel->createEdition($values, 1, 1); + // $this->assertEquals($wikimodel->createEdition($values, 1, 1), 1, 'Failed to create wiki edition'); - // $this->assertTrue($hr->remove(1)); - // $this->assertEquals(0, $hr->getCurrentRate(1)); + $editions = $wikimodel->getEditions(1); + $this->assertNotEmpty($editions, 'Failed to get wiki editions'); - // $rates = $hr->getAllByUser(1); - // $this->assertEmpty($rates); + $this->assertEquals('Security', $editions[0]['title']); + $this->assertEquals('Some content', $editions[0]['content']); } }