Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maintenance/2.0' into fix/BAP-13…
Browse files Browse the repository at this point in the history
…919_m2
  • Loading branch information
inri13666 committed Mar 1, 2017
2 parents b275ffd + 76c8d6c commit 4714fd6
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/Oro/Bundle/ConfigBundle/Config/UserScopeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function getScopeEntityIdValue($entity)
*/
protected function ensureScopeIdInitialized()
{
if (null === $this->scopeId) {
if (!$this->scopeId) {
$scopeId = 0;

$token = $this->securityContext->getToken();
Expand Down
4 changes: 2 additions & 2 deletions src/Oro/Bundle/InstallerBundle/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ protected function loadDataStep(CommandExecutor $commandExecutor, OutputInterfac
]
)
->runCommand(
'oro:workflow:definitions:load',
'oro:cron:definitions:load',
[
'--process-isolation' => true
]
)
->runCommand(
'oro:cron:definitions:load',
'oro:workflow:definitions:load',
[
'--process-isolation' => true
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
]
)
->runCommand(LoadPermissionConfigurationCommand::NAME, ['--process-isolation' => true])
->runCommand(
'oro:workflow:definitions:load',
['--process-isolation' => true]
)
->runCommand(
'oro:cron:definitions:load',
[
'--process-isolation' => true
]
)
->runCommand(
'oro:workflow:definitions:load',
['--process-isolation' => true]
)
->runCommand('oro:process:configuration:load', ['--process-isolation' => true])
->runCommand('oro:migration:data:load', ['--process-isolation' => true])
->runCommand('oro:navigation:init', ['--process-isolation' => true])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% if dropDatabase %}
{% set steps = steps|merge(['schema-drop', 'clear-config', 'clear-extend']) %}
{% endif %}
{% set steps = steps|merge(['schema-update', 'permissions', 'workflows', 'crons', 'processes', 'fixtures']) %}
{% set steps = steps|merge(['schema-update', 'permissions', 'crons', 'workflows', 'processes', 'fixtures']) %}

{% block title %}{{ 'process.step.schema.header'|trans }} - {{ parent() }}{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Oro\Component\MessageQueue\Consumption\Context;
use Oro\Component\MessageQueue\Consumption\Dbal\Extension\RedeliverOrphanMessagesDbalExtension;
use Oro\Component\MessageQueue\Test\DbalSchemaExtensionTrait;
use Oro\Component\MessageQueue\Transport\Dbal\DbalDestination;
use Oro\Component\MessageQueue\Transport\Dbal\DbalMessageConsumer;
use Psr\Log\NullLogger;

class RedeliverOrphanMessagesDbalExtensionTest extends WebTestCase
Expand Down Expand Up @@ -35,8 +37,15 @@ public function testShouldRedeliverOrphanMessages()
$connection = $this->createConnection('message_queue');
$dbal = $connection->getDBALConnection();

// test
$session = $connection->createSession();
$context = new Context($session);
$context->setLogger(new NullLogger());
$consumer = new DbalMessageConsumer($session, new DbalDestination('default'));
$context->setMessageConsumer($consumer);

$dbal->insert('message_queue', [
'consumer_id' => 'consumer-id',
'consumer_id' => $consumer->getId(),
'delivered_at' => strtotime('-1 year'),
'redelivered' => false,
'queue' => 'queue',
Expand All @@ -47,10 +56,6 @@ public function testShouldRedeliverOrphanMessages()
//guard
$this->assertGreaterThan(0, $id);

// test
$context = new Context($connection->createSession());
$context->setLogger(new NullLogger());

$extension = new RedeliverOrphanMessagesDbalExtension();
$extension->onBeforeReceive($context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ Feature: User login
Scenario: Success login
Given I am on "/user/login"
When I fill "Login" form with:
When I fill "Login Form" with:
| Username | admin |
| Password | admin |
And I press "Log in"
Then I should be on "/"
Scenario Outline: Fail login
Given I am on "/user/login"
When I fill "Login" form with:
When I fill "Login Form" with:
| Username | <login> |
| Password | <password> |
And I press "Log in"
Expand Down
11 changes: 11 additions & 0 deletions src/Oro/Bundle/UserBundle/Resources/config/oro/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ elements:
selector: "form[id^='oro_user_role_form']"
class: Oro\Bundle\UserBundle\Tests\Behat\Element\UserRoleForm

User Config Form:
selector: 'form[name="look_and_feel"]'
class: Oro\Bundle\TestFrameworkBundle\Behat\Element\Form
options:
mapping:
Use parent scope for Position: 'look_and_feel[oro_ui___navbar_position][use_parent_scope_value]'

Sided Main Menu:
selector: 'div.main-menu-sided'
class: Oro\Bundle\TestFrameworkBundle\Behat\Element\Element

pages:
Login:
class: Oro\Bundle\UserBundle\Tests\Behat\Page\Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Feature: User configuration
And I go to System/User Management/Users
And I click Configuration on admin in grid "Grid"
And I click "Display settings"
And I uncheck "look_and_feel[oro_ui___navbar_position][use_parent_scope_value]"
And I select "Left" from "Position"
And I fill "User Config Form" with:
| Use parent scope for Position | false |
| Position | Left |
When I press "Save settings"
Then I should see 1 "div.main-menu-sided" elements
Then I should see a "Sided Main Menu" element
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ public function onBeforeReceive(Context $context)

$sql = sprintf(
'UPDATE %s SET consumer_id=NULL, delivered_at=NULL, redelivered=:isRedelivered '.
'WHERE delivered_at <= :deliveredAt',
'WHERE delivered_at <= :deliveredAt AND consumer_id=:consumerId',
$connection->getTableName()
);

$affectedRows = $dbal->executeUpdate(
$sql,
[
'isRedelivered' => true,
'deliveredAt' => time() - $this->orphanTime,
'consumerId' => $context->getMessageConsumer()->getId(),
],
[
'isRedelivered' => Type::BOOLEAN,
'deliveredAt' => Type::INTEGER,
'consumerId' => Type::STRING,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public function onInterrupted(Context $context)
$context->getMessageConsumer()->reject($context->getMessage(), true);

$context->getLogger()->debug(
'[RejectMessageOnExceptionDbalExtension] Execution was interrupted and message was rejected'
'[RejectMessageOnExceptionDbalExtension] Execution was interrupted and message was rejected. {id}',
['id' => $context->getMessage()->getMessageId()]
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Oro\Component\MessageQueue\Consumption\Context;
use Oro\Component\MessageQueue\Consumption\Dbal\Extension\RedeliverOrphanMessagesDbalExtension;
use Oro\Component\MessageQueue\Transport\Dbal\DbalConnection;
use Oro\Component\MessageQueue\Transport\Dbal\DbalMessageConsumer;
use Oro\Component\MessageQueue\Transport\Dbal\DbalSession;
use Oro\Component\MessageQueue\Transport\Null\NullSession;
use Psr\Log\LoggerInterface;
Expand All @@ -23,38 +24,39 @@ public function testShouldRedeliverOrphanMessages()
->expects($this->once())
->method('executeUpdate')
->with('UPDATE tableName SET consumer_id=NULL, delivered_at=NULL, redelivered=:isRedelivered '.
'WHERE delivered_at <= :deliveredAt')
->will($this->returnValue(3))
;
'WHERE delivered_at <= :deliveredAt AND consumer_id=:consumerId')
->will($this->returnValue(3));

$connection = $this->createConnectionMock();
$connection
->expects($this->once())
->method('getDBALConnection')
->will($this->returnValue($dbal))
;
->will($this->returnValue($dbal));
$connection
->expects($this->once())
->method('getTableName')
->will($this->returnValue('tableName'))
;
->will($this->returnValue('tableName'));

$session = $this->createSessionMock();
$session
->expects($this->once())
->method('getConnection')
->will($this->returnValue($connection))
;
->will($this->returnValue($connection));

$logger = $this->createLoggerMock();
$logger
->expects($this->once())
->method('alert')
->with('[RedeliverOrphanMessagesDbalExtension] Orphans were found and redelivered. number: 3')
;
->with('[RedeliverOrphanMessagesDbalExtension] Orphans were found and redelivered. number: 3');

$consumer = $this->createMock(DbalMessageConsumer::class);
$consumer
->expects($this->once())
->method('getId')
->willReturn(123);
$context = new Context($session);
$context->setLogger($logger);
$context->setMessageConsumer($consumer);

$extension = new RedeliverOrphanMessagesDbalExtension();
$extension->onBeforeReceive($context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ public function testShouldDoNothingIfMessageIsMissing()
public function testShouldRejectMessage()
{
$message = new NullMessage();
$message->setMessageId(123);

$logger = $this->createLoggerMock();
$logger
->expects($this->once())
->method('debug')
->with('[RejectMessageOnExceptionDbalExtension] Execution was interrupted and message was rejected')
->with(
'[RejectMessageOnExceptionDbalExtension] Execution was interrupted and message was rejected. {id}',
['id' => '123']
)
;

$consumer = $this->createMessageConsumerMock();
Expand Down
Loading

0 comments on commit 4714fd6

Please sign in to comment.