Run code sniffer on full tests directory, merge commands into one
[MAILPOET-2429]
This commit is contained in:
committed by
Jack Kitterhing
parent
112273e3e6
commit
e1132f9e92
50
RoboFile.php
50
RoboFile.php
@@ -345,28 +345,38 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function qaCodeSniffer($severity='errors') {
|
function qaCodeSniffer($severity='errors') {
|
||||||
if ($severity === 'all') {
|
$severityFlag = $severity === 'all' ? '-w' : '-n';
|
||||||
$severityFlag = '-w';
|
$task = implode(' ', [
|
||||||
} else {
|
'./tasks/code_sniffer/vendor/bin/phpcs',
|
||||||
$severityFlag = '-n';
|
'--extensions=php',
|
||||||
}
|
$severityFlag,
|
||||||
|
'--standard=tasks/code_sniffer/MailPoet',
|
||||||
|
]);
|
||||||
|
|
||||||
return $this->collectionBuilder()
|
return $this->collectionBuilder()
|
||||||
->taskExec(
|
|
||||||
'./tasks/code_sniffer/vendor/bin/phpcs ' .
|
// PHP >= 5.6 for lib & tests
|
||||||
'--standard=./tasks/code_sniffer/MailPoet ' .
|
->taskExec($task)
|
||||||
'--runtime-set testVersion 5.6-7.3 ' .
|
->rawArg('--runtime-set testVersion 5.6-7.3')
|
||||||
'--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,' .
|
->arg('--ignore=' . implode(',', [
|
||||||
'./lib/Util/pQuery/*,./lib/Config/PopulatorData/Templates/* ' .
|
'lib/Config/PopulatorData/Templates',
|
||||||
'lib/ ' .
|
'lib/Util/CSS.php',
|
||||||
$severityFlag
|
'lib/Util/Sudzy',
|
||||||
|
'lib/Util/pQuery',
|
||||||
|
'lib/Util/XLSXWriter.php',
|
||||||
|
'tests/_data',
|
||||||
|
'tests/_output',
|
||||||
|
'tests/_support',
|
||||||
|
'tests/Actions.php',
|
||||||
|
'tests/integration/_bootstrap.php',
|
||||||
|
'tests/integration/_fixtures.php',
|
||||||
|
'tests/unit/_bootstrap.php',
|
||||||
|
])
|
||||||
)
|
)
|
||||||
->taskExec(
|
->args([
|
||||||
'./tasks/code_sniffer/vendor/bin/phpcs ' .
|
'lib',
|
||||||
'--standard=./tasks/code_sniffer/MailPoet ' .
|
'tests',
|
||||||
'--runtime-set testVersion 5.6-7.3 ' .
|
])
|
||||||
'--ignore=./tests/unit/_bootstrap.php,./tests/unit/_fixtures.php,./tests/integration/_bootstrap.php,./tests/integration/_fixtures.php ' .
|
|
||||||
'tests/unit tests/integration tests/acceptance tests/DataFactories ' .
|
|
||||||
$severityFlag
|
|
||||||
)
|
)
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ class DataGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run($generator_name) {
|
function run($generator_name) {
|
||||||
ini_set('memory_limit','1024M');
|
ini_set('memory_limit', '1024M');
|
||||||
$timer = time();
|
$timer = time();
|
||||||
try {
|
try {
|
||||||
$generator = $this->createGenerator($generator_name);
|
$generator = $this->createGenerator($generator_name);
|
||||||
@@ -41,7 +41,7 @@ class DataGenerator {
|
|||||||
|
|
||||||
private function log($timer, $message) {
|
private function log($timer, $message) {
|
||||||
$duration = time() - $timer;
|
$duration = time() - $timer;
|
||||||
$memory = round(memory_get_usage()/1048576);
|
$memory = round(memory_get_usage() / 1048576);
|
||||||
$this->console->message("[{$duration}s][{$memory}MB] $message")->writeln();
|
$this->console->message("[{$duration}s][{$memory}MB] $message")->writeln();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ class WooCommercePastRevenues {
|
|||||||
// Create subscribers
|
// Create subscribers
|
||||||
$subscribers_ids = [];
|
$subscribers_ids = [];
|
||||||
$subscriber_emails = [];
|
$subscriber_emails = [];
|
||||||
for ($i=1; $i <= self::SUBSCRIBERS_COUNT; $i++) {
|
for ($i = 1; $i <= self::SUBSCRIBERS_COUNT; $i++) {
|
||||||
$email = "address$i@email.com";
|
$email = "address$i@email.com";
|
||||||
$subscriber = $this->createSubscriber("address$i@email.com", "last_name_$i", $minimal_created_at_date, $subscribers_list);
|
$subscriber = $this->createSubscriber("address$i@email.com", "last_name_$i", $minimal_created_at_date, $subscribers_list);
|
||||||
$subscribers_ids[] = $subscriber->id;
|
$subscribers_ids[] = $subscriber->id;
|
||||||
@@ -59,7 +59,7 @@ class WooCommercePastRevenues {
|
|||||||
// Products
|
// Products
|
||||||
$product_category = $this->createProductCategory('WC Revenues Test Category', 'revenues-test-cat');
|
$product_category = $this->createProductCategory('WC Revenues Test Category', 'revenues-test-cat');
|
||||||
$products = [];
|
$products = [];
|
||||||
for ($i=1; $i <= self::PRODUCTS_COUNT; $i++) {
|
for ($i = 1; $i <= self::PRODUCTS_COUNT; $i++) {
|
||||||
$products[] = $this->createProduct("Product $i", 100, [$product_category->term_id]);
|
$products[] = $this->createProduct("Product $i", 100, [$product_category->term_id]);
|
||||||
}
|
}
|
||||||
yield "Products done";
|
yield "Products done";
|
||||||
@@ -200,7 +200,7 @@ class WooCommercePastRevenues {
|
|||||||
$sent_standard_newsletters
|
$sent_standard_newsletters
|
||||||
);
|
);
|
||||||
// Pick amount of received emails and generate opens and clicks
|
// Pick amount of received emails and generate opens and clicks
|
||||||
$opened_count = floor(count($subscriber_received_emails)/rand(2,5));
|
$opened_count = floor(count($subscriber_received_emails) / rand(2, 5));
|
||||||
$emails_to_click = array_intersect_key(
|
$emails_to_click = array_intersect_key(
|
||||||
$subscriber_received_emails,
|
$subscriber_received_emails,
|
||||||
array_flip(array_rand($subscriber_received_emails, $opened_count))
|
array_flip(array_rand($subscriber_received_emails, $opened_count))
|
||||||
@@ -333,18 +333,18 @@ class WooCommercePastRevenues {
|
|||||||
|
|
||||||
// Add subscribers to task
|
// Add subscribers to task
|
||||||
$batch_data = [];
|
$batch_data = [];
|
||||||
foreach($subscribers_ids as $subscriber_id) {
|
foreach ($subscribers_ids as $subscriber_id) {
|
||||||
$batch_data[] = "({$task->id}, $subscriber_id, 1, '$sent_at')";
|
$batch_data[] = "({$task->id}, $subscriber_id, 1, '$sent_at')";
|
||||||
if (count($batch_data) % 1000 === 0) {
|
if (count($batch_data) % 1000 === 0) {
|
||||||
\ORM::rawExecute(
|
\ORM::rawExecute(
|
||||||
"INSERT INTO " . ScheduledTaskSubscriber::$_table . " (`task_id`, `subscriber_id`, `processed`, `created_at`) VALUES " . implode(', ', $batch_data)
|
"INSERT INTO " . ScheduledTaskSubscriber::$_table . " (`task_id`, `subscriber_id`, `processed`, `created_at`) VALUES " . implode(', ', $batch_data)
|
||||||
);
|
);
|
||||||
$batch_data = [];
|
$batch_data = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($batch_data) {
|
if ($batch_data) {
|
||||||
\ORM::rawExecute(
|
\ORM::rawExecute(
|
||||||
"INSERT INTO " . ScheduledTaskSubscriber::$_table . " (`task_id`, `subscriber_id`, `processed`, `created_at`) VALUES " . implode(', ', $batch_data)
|
"INSERT INTO " . ScheduledTaskSubscriber::$_table . " (`task_id`, `subscriber_id`, `processed`, `created_at`) VALUES " . implode(', ', $batch_data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +438,7 @@ class WooCommercePastRevenues {
|
|||||||
$order = wc_create_order();
|
$order = wc_create_order();
|
||||||
$order->set_address($address, 'billing');
|
$order->set_address($address, 'billing');
|
||||||
$order->set_address($address, 'shipping');
|
$order->set_address($address, 'shipping');
|
||||||
foreach($products as $product) {
|
foreach ($products as $product) {
|
||||||
$order->add_product($product);
|
$order->add_product($product);
|
||||||
}
|
}
|
||||||
$order->calculate_totals();
|
$order->calculate_totals();
|
||||||
|
@@ -179,4 +179,4 @@ class DynamicSegmentFilter {
|
|||||||
public function toSql($orm) {
|
public function toSql($orm) {
|
||||||
return $orm->whereIn(Subscriber::$_table . '.id', $this->ids);
|
return $orm->whereIn(Subscriber::$_table . '.id', $this->ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Codeception\Util\Fixtures;
|
use Codeception\Util\Fixtures;
|
||||||
|
|
||||||
$newsletter_body_text =
|
$newsletter_body_text =
|
||||||
|
Reference in New Issue
Block a user