View gist:afda988bc6d03d5c5fff4a11002d9580
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
Создание модульных и интеграционных тестов | |
Создано и настроено окружение для использования Codeception как надстройки над PhpUnit, теперь мы можем писать тесты (не только модульные на чистом PhpUnit, но и интеграционные, требующие запущенного приложения), а ещё получать статистику по тому, какой процент кода у нас покрыт этими самыми тестами. | |
Команды: | |
vendor/bin/codecept run - запустить все тесты | |
vendor/bin/codecept run unit --coverage-html='coverage' - сформировать отчёт по степени покрытия кода тестами | |
Контроллеры тонкие, их тестировать не нужно, да и нет возможности, потому что тесты запускаются в консоли, а там нет: веб-сервера, урла, сессий, куков и т.п. Проект запускается как консольное приложение. Так что всё сошлось. | |
View sort.php
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
usort($res, function ($a, $b) | |
{ | |
return strcmp($a["LastName"], $b["LastName"]); | |
}); |
View regexp.php
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
preg_match('/\((.+)\)/', $str, $m); | |
echo $m[1]; |
View latin.js
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
function Latin(obj) { | |
if (/^[a-zA-Z0-9 ,.\-:"()]*?$/.test(obj.value)) | |
obj.defaultValue = obj.value; | |
else | |
obj.value = obj.defaultValue; | |
} | |
<input onkeyup="Latin(this);"> |
View starRating.html
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
<div class="star-ratings-sprite"> | |
<span style="width:90%" class="star-ratings-sprite-rating"></span> | |
</div> | |
.star-ratings-sprite { | |
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/2605/star-rating-sprite.png") repeat-x; | |
font-size: 0; | |
height: 21px; | |
line-height: 0; | |
overflow: hidden; |
View php mb_strimwidth.php
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
$title = mb_strimwidth($title, 0, 85, "..."); |
View module.php
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
?> | |
<h1>Отзывы</h1> | |
<ul id="tabs"> | |
<li><a title="tab1" href="#">Опубликованные отзывы</a></li> | |
<li><a title="tab2" href="#">Неопубликованные отзывы</a></li> | |
</ul> | |
<div id="content"> | |
<?php |
View module.php
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
?> | |
<style> | |
#content{ | |
width:820px; | |
} | |
ul{ | |
margin: 0; | |
border: 1px solid #d8d8d8; | |
padding-left: 0; |
View payment.php
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
Подключение эквайринга | |
Необходимо получить от клиента доступы в кабинет пользователя нужной платежной системы. | |
Для webpay сначала дается доступ к тестовому кабинету. В нем проверяется правильность подключения и деньги не списываются при оплате. Когда все готово и работает – клиент пишет в webpay, и ему дают доступы от рабочего кабинета. | |
Для bepaid кабинет один. | |
Произвести необходимую настройку в кабинете пользователя платежной системы. | |
Для webpay - задать секретный ключ, прописать страницы error, success, notify. Забираем из кабинета id магазина. | |
Для bepaid надо в кабинете настроить данные тестового платежа – срок действия тестовой карточки и прочее. Также забираем id магазина. |
View anti-spam.php
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
Для eForm (evolutionCMS). | |
Создаем сниппет checkSpamTime, вставляем в него код: | |
<?php | |
if ($_SESSION['now']) | |
{ | |
$_SESSION['lt'] = $_SESSION['now']; | |
} | |
$_SESSION['now'] = microtime(true); |
NewerOlder