8000 [Workflow] CS tweaks by ro0NL · Pull Request #19187 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Workflow] CS tweaks #19187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
opinionated
  • Loading branch information
ro0NL committed Jun 28, 2016
commit 8d9bc359e1ccba022cacf7f4e929391e489f5e48
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function addPlace($place)
throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place));
}

if (!$this->places) {
if (!count($this->places)) {
$this->initialPlace = $place;
}

Expand Down
13 changes: 13 additions & 0 deletions src/Symfony/Component/Workflow/Tests/WorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ public function testConstructorWithUniqueTransitionOutputInterfaceAndSimpleWorkf
new Workflow($definition, new ScalarMarkingStore());
}

/**
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @expectedExceptionMessage The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".
*/
public function testGetMarkingWithInvalidStoreReturn()
{
$subject = new \stdClass();
$subject->marking = null;
$workflow = new Workflow(new Definition(), $this->getMock(MarkingStoreInterface::class));

$workflow->getMarking($subject);
}

/**
* @expectedException \Symfony\Component\Workflow\Exception\LogicException
* @expectedExceptionMessage The Marking is empty and there is no initial place for workflow "unnamed".
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Workflow/Workflow.php
41C3
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public function getMarking($subject)
{
$marking = $this->markingStore->getMarking($subject);

if (!$marking instanceof Marking) {
throw new LogicException(sprintf('The value returned by the MarkingStore is not an instance of "%s" for workflow "%s".', Marking::class, $this->name));
Copy link
Contributor Author
@ro0NL ro0NL Jun 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For being a contract check, i guess LogicException is just fine also :) (opposed to UnexpectedValue) 😕

}

// check if the subject is already in the workflow
if (!$marking->getPlaces()) {
if (!$this->definition->getInitialPlace()) {
Expand Down
0