Pass Behat Tests Example

Case 1 - Actual output contains line break, PR547 Problem In DatasetViewContext.php: /** * @Then there is a :arg1 meta tag :arg2 with value :arg3 */ public function thereIsAMetaTagWithValue($arg1, $arg2, $arg3) { $metaNode = $this->minkContext->getSession()->getPage()->find('xpath', "//meta[@$arg1='$arg2' and @content='$arg3']"); PHPUnit_Framework_Assert::assertNotNull($metaNode); } In dataset-metadata-link-preview.feature: @wip @issue-513 Scenario: Can be parsed by preview tools that use HTML meta-tags (e.g: search engines) Given I am not logged in to Gigadb web site When I am on "/dataset/100002" Then there is a meta tag "description" with value "The Adelie penguin (Pygoscelis adeliae) is an iconic penguin of moderate stature and a tuxedo of black and white feathers. The penguins are only found in the Antarctic region and surrounding islands. Being very sensitive to climate change, and due to changes in their behavior based on minor shifts in climate, they are often used as a barometer of the Antarctic. With its status as one of the adorable and cuddly flightless birds of Antarctica, they serve as an example for conservation, and as a result they are now categorised at low risk for endangerment. The sequence of the penguin can be of use in understanding the genetic underpinnings of its evolutionary traits and adaptation to its extreme environment; its unique system of feathers; its prowess as a diver; and its sensitivity to climate change. We hope that this genome data will further our understanding of one of the most remarkable creatures to waddle the planet Earth. We sequenced the genome of an adult male from Inexpressible Island, Ross Sea, Antartica (provided by David Lambert) to a depth of approximately 60X with short reads from a series of libraries with various insert sizes (200bp- 20kb). The assembled scaffolds of high quality sequences total 1.23 Gb, with the contig and scaffold N50 values of 19 kb and 5 mb respectively. We identified 15,270 protein-coding genes with a mean length of 21.3 kb." The error is: ...

January 8, 2021 · 9 min · 1709 words · Ken Cho

To resolve XDebug dependency problem

Problem ---> Running in 4c7fe5b9cf5e pecl/xdebug requires PHP (version >= 7.2.0, version <= 8.0.99), installed version is 7.1.30 No valid packages found install failed ERROR: Service 'test' failed to build : The command '/bin/sh -c if [ ${INSTALL_XDEBUG} = true ]; then if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then pecl install xdebug-2.5.5; else pecl install xdebug; fi && docker-php-ext-enable xdebug ;fi' returned a non-zero code: 1 Effect The docker-compose run --rm test cannot be run. Then the test service cannot be built. ...

January 7, 2021 · 2 min · 216 words · Ken Cho

How to add favicon to a Hugo page

What is a favivon A favicon is a small 16×16 pixel icon that serves as branding for your website. Its main purpose is to help visitors locate your page easier when they have multiple tabs open. Where to find favicon? Go to favicon.io to select the suitable one. Steps Go to favicon.io Download the favicon.zip and unzip Place the files in /static/image/ Add the following code to /layouts/partials/header.html <link rel="icon" href="/image/favicon.ico" type="/image" /> <link rel="apple-touch-icon" sizes="180x180" href="/image/apple-touch-icon.png"> <link rel="icon" type="image" sizes="32x32" href="/image/favicon-32x32.png"> <link rel="icon" type="image" sizes="16x16" href="/image/favicon-16x16.png"> <link rel="manifest" href="/site.webmanifest.json"> Edit the site.webmanifest in static folder { "name": "", "short_name": "favicon", "icons": [ { "src": "image/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }, { "src": "image/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" }, { "src": "image/apple-touch-icon.png", "sizes": "180x180", "type": "image/png" } ], "theme_color": "#ffffff", "background_color": "#ffffff", "display": "standalone" } Where to check the final implementation Go to Favicon checker ...

October 27, 2020 · 1 min · 154 words · Ken Cho

OOP basics

Here is the OOP crash course video: And here is the Introduction to programming and Computer Science video Reference OOP programming basics Introduction to programming and computer science ...

October 5, 2020 · 1 min · 28 words · Ken Cho

How to add delete button

Problem Add Delete button in AdminFile/update under New Attribute Create actionDeleteAttr Pass Behat tests How Add Delete button in /protected/adminFile/_form.php <tbody> <?php foreach($model->fileAttributes as $fa) { ?> <tr class="row-edit-<?= $fa->id ?>"> <td> <?= $fa->attribute->attribute_name ?> </td> <td> <?= $fa->value ?> </td> <td> <?= $fa->unit ? $fa->unit->name : '' ?> </td> <td><a role="button" class="btn btn-edit js-edit" data="<?= $fa->id ?>">Edit</a></td> <td><a role="button" class="btn js-delete" name="delete_attr" data="<?= $fa->id ?>">Delete</a></td> </tr> <?php } ?> </tbody> <script> $('.js-delete').click(function (e) { e.preventDefault(); id = $(this).attr('data'); console.log(id); row = $('.row-edit-' + id); console.log(row); if (id) { $.post('/adminFile/deleteAttr', { 'id': id }, function(result) { if (result) { // console.log(result); } }, 'json'); } window.location.reload(); }) </script> Create actionDeleteAttr in /controller/AdminFileController.php public function actionDeleteAttr() { if (!Yii::app()->request->isPostRequest) throw new CHttpException(404, "The requested page does not exist."); if (isset($_POST['id'])) { $attribute = FileAttributes::model()->findByPk($_POST['id']); if ($attribute) { $attribute->delete(); Yii::app()->end(); } } } Create admin-file.feature @admin-file @issue-457 Feature: An admin user can edit and delete attribute in admin file page As an admin user I can edit/delete attribute So that I can associate various attributes to files Background: Given Gigadb web site is loaded with production-like data @ok @issue-457 @javascript Scenario: Guest user cannot visit admin file update page Given I am not logged in to Gigadb web site When I go to "/adminFile/update/" Then I should see "Login" @ok @issue-457 @javascript Scenario: Sign in as admin and visit admin file update page and see New Attribute, Edit, Delete buttons Given I sign in as an admin When I am on "/adminFile/update/id/13973" Then I should see a button "New Attribute" And I should see a button input "Edit" And I should see a button input "Delete" @ok @issue-457 @javascript Scenario: Sign in as admin to delete attribute Given I sign in as an admin And I am on "/adminFile/update/id/13973" And I should see a button input "Delete" When I press "Delete" And I wait "3" seconds Then I should not see a button "Delete" Run behat test with Database set up 4.1 only accptance test #!/usr/bin/env bash set -e -u ./tests/acceptance #./tests/unit_functional #./tests/coverage 4.2 change tag to @wip ...

September 23, 2020 · 3 min · 508 words · Ken Cho