Skip to content

Instantly share code, notes, and snippets.

View undertext's full-sized avatar

Yaroslav Kharchenko undertext

View GitHub Profile
$logger = new Logger('appLogger');
$logger->pushHandler(new StreamHandler("monolog_php_errors.log"));
$logger->error('This is my error log message from monolog logger');
@undertext
undertext / logging.php
Created January 29, 2020 15:17
PHP logging
<?php
ini_set('log_errors', TRUE);
ini_set('error_log', 'php_errors.log');
ini_set('error_reporting', E_ALL);
$notArray = 'string';
array_pop($notArray);
@undertext
undertext / UrbanDefinitionListBlockJavascriptTest.php
Last active July 4, 2019 18:15
UrbanDefinitionListBlockJavascriptTest
<?php
namespace Drupal\tests\urban_module\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Tests urban definition list block (including JS functionality).
*/
class UrbanDefinitionListBlockJavascriptTest extends WebDriverTestBase {
@undertext
undertext / docker-compose.yml
Created May 6, 2019 11:24
docker-compose-selenium
version: "3"
services:
mariadb:
container_name: "drupal_testing_mariadb"
image: wodby/mariadb
container_name: "mariadb"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: drupal
<?php
namespace Drupal\tests\urban_module\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests urban definition list block.
*/
class UrbanDefinitionListBlockTest extends BrowserTestBase {
<?php
namespace Drupal\urban_module\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
<?php
namespace Drupal\tests\urban_module\Kernel;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
<?php
function urban_module_node_presave(NodeInterface $node) {
if ($node->bundle() == 'urban_definition') {
/** @var \Drupal\urban_module\Service\UrbanDictionaryService $ubService */
$ubService = \Drupal::service('urban_module.service');
$definition = $ubService->getDefinition($node->getTitle());
if (!empty($definition)) {
$node->title->value = $definition->getTerm();
$node->field_definition->value = $definition->getDefinition();
<testsuites>
<testsuite name="unit">
<file>./tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<?php
namespace Drupal\tests\urban_module\Unit;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\urban_module\Service\UrbanDictionaryService;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use Psr\Http\Message\RequestInterface;