Skip to main content

Posts

Showing posts from May, 2020

Unit Test With Drupal 8

Types of tests: Writing tests All PHP-based tests for Drupal core are written using the industry-standard PHPUnit framework, with Drupal extensions. There are several categories of tests; each has its own purpose, base class, namespace, and directory: Unit tests: Purpose : Test functionality of a class if the Drupal environment (database, settings, etc.) and web browser are not needed for the test, or if the Drupal environment can be replaced by a "mock" object. Base class :   \Drupal\Tests\UnitTestCase Namespace : \Drupal\Tests\yourmodule\Unit (or a subdirectory) Directory location : yourmodule/tests/src/Unit (or a subdirectory) Kernel tests: Purpose : Test functionality of a class if the full Drupal environment and web browser are not needed for the test, but the functionality has significant Drupal dependencies that cannot easily be mocked. Kernel tests can access services, the database, and a minimal mocked file system, and they use an in-memory pseudo-installation. Howe...

Best Way to use composer with drupal in multi environment(dev,stage,prod)

NOTE :  it’s extremely important that your development environment is using the same version of PHP that the target production environment will use. Otherwise Composer may download packages that won’t work in production.   (With larger development teams, using something like  Vagrant  or Docker for local development can help ensure compatibility between local development instances and the production stack How do I download modules and themes: 1 - composer require drupal/devel  it would download the module to web/modules/contrib. If you want to change the download destination, you can alter the paths in your composer.json.  Development Dependencies: composer require --dev drupal/devel  For example, since the Devel module shouldn’t be used in a production environment, you may only want it to get downloaded on development environments. With Composer, you can achieve this by passing the --dev flag to the composer require command. This wi...

Chatbot API for Drupal 8

Historically, we have many ways of serving content digitally: through a website, mobile apps, social media, RSS feeds, RESTful APIs ,email.  Now we have a new player in the game: chatbots and personal assistants.  Chatbot API for Drupal 8