Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Hotfix #279 #280

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

thomasvargiu
Copy link
Contributor

Fix issue #279

@thomasvargiu thomasvargiu changed the base branch from master to develop February 15, 2019 18:00
'class_map' => [
'Foo' => 'Foo',
],
]
Copy link
Member

Choose a reason for hiding this comment

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

missing trailing comma

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

$lazyServicesProperty->setAccessible(true);

self::assertSame($config['delegators'], $delegatorsProperty->getValue($serviceManager));
self::assertSame($config['lazy_services'], $lazyServicesProperty->getValue($serviceManager));
Copy link
Member

Choose a reason for hiding this comment

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

I am not convinced to that test, as we are using reflection to check internal state of the object. Is there something what we can notice "outside" that it's wrong configured? I'm afraid that test like that is not future-proof.

Copy link
Member

Choose a reason for hiding this comment

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

@thomasvargiu I agree with @webimpress here. What is the side effect that occurs currently? The test should be checking to ensure that side effect does not occur with your patch.

With delegators, that's generally pretty easy - you can check that a class is not double-decorated after retrieval. With lazy services, I'm assuming that the fact that you get an array value in a class map will likely throw an error on retrieval — if that's the case, test that you do not get that exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@webimpress @weierophinney I changed it, configuration used in test was wrong.
But I also changed the implementation to merge delegators. Let me know.

@weierophinney
Copy link
Member

@thomasvargiu

Run composer cs-fix, commit, and push, please. 😄

@thomasvargiu
Copy link
Contributor Author

@weierophinney fixed it

Copy link

@dennybrandes dennybrandes left a comment

Choose a reason for hiding this comment

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

Looks good to me

@michalbundyra
Copy link
Member

@thomasvargiu It looks like a hotfix, so I think you should target master here.

@thomasvargiu thomasvargiu changed the base branch from develop to master July 4, 2019 09:41
@thomasvargiu thomasvargiu changed the base branch from master to develop July 4, 2019 09:42
@thomasvargiu thomasvargiu changed the base branch from develop to master July 4, 2019 10:05
@thomasvargiu
Copy link
Contributor Author

@webimpress I rewrite it on master base

$instance = $serviceManager->get('Foo');

self::assertInstanceOf(InvokableObject::class, $instance);
self::assertSame(1, $instance->getOptions()['inc']);

Choose a reason for hiding this comment

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

I think a single test should have only one assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO, I think it can be a valid assertion. Instead to throw an error in case of failure I'm asserting that the second assertion depends on the first assertion. If it's enough the phpunit error catch for you, I can remove the first assertion. Different point of view :)
Someonelse opinion?

Copy link
Member

Choose a reason for hiding this comment

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

It's fine to have multiple assertions as long as they are connected, imho. Kinda "one logic assertion". I was checking what people say about it, and I see some approach to write test with single assertion. I see the advantages of it, but I think this approach would be more messy. You can see that in other tests usually we have more than one assertion, but these are connected - as you are saying, @thomasvargiu.

See: https://softwareengineering.stackexchange.com/questions/7823/is-it-ok-to-have-multiple-asserts-in-a-single-unit-test

any my favourite comment there is:

A single assert per unit test is a great way to test the reader's ability to scroll up and down.

🤣

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-servicemanager; a new issue has been opened at laminas/laminas-servicemanager#3.

@weierophinney
Copy link
Member

This repository has been moved to laminas/laminas-servicemanager. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:

  • Squash all commits in your branch (git rebase -i origin/{branch})
  • Make a note of all changed files (`git diff --name-only origin/{branch}...HEAD
  • Run the laminas/laminas-migration tool on the code.
  • Clone laminas/laminas-servicemanager to another directory.
  • Copy the files from the second bullet point to the clone of laminas/laminas-servicemanager.
  • In your clone of laminas/laminas-servicemanager, commit the files, push to your fork, and open the new PR.
    We will be providing tooling via laminas/laminas-migration soon to help automate the process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants