Skip to content
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

Changed service definition + fixed testcases #29

Merged
merged 1 commit into from
Oct 20, 2019

Conversation

jeroendk
Copy link
Contributor

As mentioned in #27 I think it is better to use keys for the service definition, also most of the services already had keys so this is more consistent.

In addition i fixed the failing tests.

@jeroendk
Copy link
Contributor Author

@Nightbr Phpsepc still fails because the function subscriberHash is now static in DrewM\MailChimp. Any idea on how to fix this?

Copy link
Member

@Nightbr Nightbr left a comment

Choose a reason for hiding this comment

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

If you want to use ids for services, you have to set class manually (no autowire here).

For the problem with drewm/mailchimp-api. You need to replace in ListRepository.php:
$this->mailchimp->subscriberHash by MailChimp::subscriberHash because subscriberHash became a static method.

After that, you need to fix ListRepositoryTest.php (no time for this, sorry, but if you can manage it, we will be able to merge this and release a version 👍 ).

Welp/MailchimpBundle/Subscriber/ListRepository                          
  48  - it subscribe a subscriber
      unexpected method call on Double\DrewM\MailChimp\MailChimp\P34:
        - put(
              "lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691",
              ["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "subscribed"]
          )
      expected calls were:
        - subscriberHash(
              exact("[email protected]")
          )
        - success(
      
          )
        - get(
              exact("lists/ba039c6198")
          )
        - get(
              exact("lists/notfound")
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "subscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "unsubscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "pending"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "cleaned"])
          )

Welp/MailchimpBundle/Subscriber/ListRepository                        
  59  - it unsubscribe a subscriber
      unexpected method call on Double\DrewM\MailChimp\MailChimp\P36:
        - put(
              "lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691",
              ["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "unsubscribed"]
          )
      expected calls were:
        - subscriberHash(
              exact("[email protected]")
          )
        - success(
      
          )
        - get(
              exact("lists/ba039c6198")
          )
        - get(
              exact("lists/notfound")
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "subscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "unsubscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "pending"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "cleaned"])
          )

Welp/MailchimpBundle/Subscriber/ListRepository                        
  64  - it pending a subscriber
      unexpected method call on Double\DrewM\MailChimp\MailChimp\P38:
        - put(
              "lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691",
              ["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "pending"]
          )
      expected calls were:
        - subscriberHash(
              exact("[email protected]")
          )
        - success(
      
          )
        - get(
              exact("lists/ba039c6198")
          )
        - get(
              exact("lists/notfound")
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "subscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "unsubscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "pending"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "cleaned"])
          )

Welp/MailchimpBundle/Subscriber/ListRepository                        
  69  - it clean a subscriber
      unexpected method call on Double\DrewM\MailChimp\MailChimp\P40:
        - put(
              "lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691",
              ["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "cleaned"]
          )
      expected calls were:
        - subscriberHash(
              exact("[email protected]")
          )
        - success(
      
          )
        - get(
              exact("lists/ba039c6198")
          )
        - get(
              exact("lists/notfound")
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "subscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "unsubscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "pending"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "cleaned"])
          )

Welp/MailchimpBundle/Subscriber/ListRepository                        
  74  - it delete a subscriber
      unexpected method call on Double\DrewM\MailChimp\MailChimp\P42:
        - delete(
              "lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691"
          )
      expected calls were:
        - subscriberHash(
              exact("[email protected]")
          )
        - success(
      
          )
        - get(
              exact("lists/ba039c6198")
          )
        - get(
              exact("lists/notfound")
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "subscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "unsubscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "pending"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "cleaned"])
          )
        - delete(
              exact("lists/ba039c6198/members/md5ofthesubscribermail")
          )

Welp/MailchimpBundle/Subscriber/ListRepository                        
  81  - it update a subscriber
      unexpected method call on Double\DrewM\MailChimp\MailChimp\P44:
        - patch(
              "lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691",
              ["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html"]
          )
      expected calls were:
        - subscriberHash(
              exact("[email protected]")
          )
        - success(
      
          )
        - get(
              exact("lists/ba039c6198")
          )
        - get(
              exact("lists/notfound")
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "subscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "unsubscribed"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "pending"])
          )
        - put(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html", "status" => "cleaned"])
          )
        - patch(
              exact("lists/ba039c6198/members/md5ofthesubscribermail"),
              exact(["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html"])
          )

src/Resources/config/services.yml Show resolved Hide resolved
@Nightbr
Copy link
Member

Nightbr commented Oct 19, 2019

Add to that, I think we should lock the version of drewm/mailchimp-api to 2.5.* to avoid this sort of thing in the future.

composer.json
"drewm/mailchimp-api": "2.5.*"

@jeroendk
Copy link
Contributor Author

So i changed "md5ofthesubscribermail" for the md5 hash of the test email because you can not mock a static method. In there Github they suggest to create your own wrapper/proxy but that might be a little to much for this one thing?
phpspec/prophecy#20 (comment)

Copy link
Member

@Nightbr Nightbr left a comment

Choose a reason for hiding this comment

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

👍 Thanks for your contribution 🎉
I will merge this and ship a release soon :)

@Nightbr Nightbr merged commit 7aa801c into welpdev:master Oct 20, 2019
@Nightbr
Copy link
Member

Nightbr commented Oct 20, 2019

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

Successfully merging this pull request may close these issues.

2 participants