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

[BUG] After last update something wrong with a Stub. #32

Closed
m1ome opened this issue Feb 21, 2015 · 10 comments
Closed

[BUG] After last update something wrong with a Stub. #32

m1ome opened this issue Feb 21, 2015 · 10 comments
Labels

Comments

@m1ome
Copy link
Collaborator

m1ome commented Feb 21, 2015

I have a stub:

Stub::on('Api\Models\AtmLog')->method('create', function($data=null, $whitelist=null) {
    return false;
});

Api\Models\AtmLog:

class ApiLog extends \Spec\Helper\BaseModel {
}

\Spec\Helper\BaseModel:

<?php
class BaseModel extends \Phalcon\Mvc\Model {

  public static function find($parameters=null){
    return parent::find($parameters);
  }

  public static function findFirst($parameters=null){
    return parent::findFirst($parameters);
  }

  public function save($data=null, $whiteList=null){
    return parent::save($data, $whiteList);
  }

  public function create($data=null, $whiteList=null){
    return parent::create($data, $whiteList);
  }

  public function delete() {
    return parent::delete();
  }
}

It correctly passes into create if i dump get_class($this) in create it will show Api\Models\ApiLog but Stub doesn't work. Maybe some BC was broken?

@m1ome
Copy link
Collaborator Author

m1ome commented Feb 21, 2015

Version 1.0.0 is fine.

@m1ome
Copy link
Collaborator Author

m1ome commented Feb 21, 2015

It's bug in 1.0.6 checked and 1.0.5 passed test.

@m1ome
Copy link
Collaborator Author

m1ome commented Feb 21, 2015

I think 1225503 can break a BC.

@jails
Copy link
Contributor

jails commented Feb 21, 2015

Weird, I'm not able to reproduce. https://github.com/jails/temp/commit/bd61dcdaf2380905ecf6f9ff4f7baa102afe441d gives https://travis-ci.org/jails/temp/jobs/51644921 so looks like the method is corrected intercepted in the above example.

@m1ome
Copy link
Collaborator Author

m1ome commented Feb 21, 2015

How can i dump stubbed methods or something else? To provide more debug info.

@jails
Copy link
Contributor

jails commented Feb 21, 2015

Stub::registered() should return all stubbed methods but if there's a glitch somewhere, the easier way would be to clone https://github.com/jails/temp (the dev branch) and tweak it to reproduce your actual issue on it because I probably missed something somewhere since I wasn't able to reproduce it.

@m1ome
Copy link
Collaborator Author

m1ome commented Feb 21, 2015

I'll try it tomorrow.

@m1ome
Copy link
Collaborator Author

m1ome commented Feb 22, 2015

Found it, it was not BC but, a strange work.
I have a code:

$args->set('include', [
  'Api'
]);

And before 1.0.6 it worked fine, but my base model is inside Spec\Helper in 1.0.6 i add:

$args->set('include', [
  'Api',
  'Spec\Helper',
]);

And it work.

@jails
Copy link
Contributor

jails commented Feb 22, 2015

Ah indeed, it's probably related to this commit 03c910c
All $args->set() calls in config files was just ignored before this commit. Previously the only option to "set" a specific value to an argument was to override its defaults values using $args->argument(). And the fact that $args->set() is now working as expected was probably the origin of your issue.

@m1ome
Copy link
Collaborator Author

m1ome commented Feb 22, 2015

I think so. It's not a BC break, more like correct work. Thanks.

@m1ome m1ome closed this as completed Feb 22, 2015
@jails jails added the invalid label Mar 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants