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

Redeclared class error #54

Closed
vernard opened this issue Jul 7, 2014 · 7 comments
Closed

Redeclared class error #54

vernard opened this issue Jul 7, 2014 · 7 comments

Comments

@vernard
Copy link

vernard commented Jul 7, 2014

I followed the basic usage part in the README. It was nice and clear until i run "bin/phpspec run". It showed this error:

PHP Fatal error: Cannot redeclare class spec\Magespec_Reviews_Model_ProductSpec in /var/ww
w/Spec\htdocs\app\code\local\Magespec\Reviews\Model\ProductSpec.php on line 14

I'm using the version 2.0.0. Error still exists when I changed the version to "dev-develop".

Please help.

@vernard
Copy link
Author

vernard commented Jul 7, 2014

Here's a copy of my composer.json file. (http://pastebin.com/2GaZk17a)

Steps to create error:

  1. Installed magento in "htdocs" folder using n98-magerun install command (https://github.com/netz98/n98-magerun#magento-installer).
  2. Run "composer install" to install magespec.
  3. Create phpspec.yml file in project directory. Here's a copy.(http://pastebin.com/wChYcu2c)
    At this point if I run "bin/phpspec", it shows the list of available commands that I can use.
    And if I run "bin/phpspec run", it shows:
    0 specs
    0 examples
    0ms
  4. Run command "bin/phpspec describe:model magespec_reviews/product"
    This showed an output:
    Specification for Magespec_Reviews_Model_Product created in D:\Projects\www\magento\1.9.0.1\spec\htdocs\app\code\local\Magespec\Reviews\Model\ProductSpec.php.
  5. Run command "bin/phpspec run"
    The error showed:
    Fatal error: Cannot redeclare class spec\Magespec_Reviews_Model_ProductSpec in D:\Projects\www\magento\1.9.0.1\spec\htdocs\app\code\local\Magespec\Reviews\Model\ProductSpec.php on line 14

Here's the full error message including the call stack. (http://pastebin.com/vcM91vYj)

Things I did to "solve" the problem (which didn't solve anything):

  • I have tried moving the ProductSpec.php file in spec folder and still nothing.
  • Tried in ubuntu virtual machine and still having the same error.
  • Used different spec like model instead of block, and a different module name, but still the same error.
  • Held my keyboard and smashed it to my head 3 times.

You see the things I did are quite useless since I have really no idea how to fix it(I'm noob, sorry)

@jamescowie
Copy link
Member

Hello @vernard I have followed the steps you provided but unfortunately I can not replicate the issue.

If you have time could you try again ? We have made some changes to MageSpec to enable support for code pools and automatic module generation that is a real benefit to users. If the problem still persists on your system please feel free to reach out to me and we can dig a little deeper to resolve the issue.

@vernard
Copy link
Author

vernard commented Jul 27, 2014

@jamescowie Sure. I really appreciate your help.

I did all of these again from scratch and the problem still persists.

There's one thing I did that took out the error. I commented line 106 of file

\vendor\magetest\magento-phpspec-extension\src\MageTest\PhpSpec\MagentoExtension\Autoloader\MageLoader.php

// return include $classFile;

Then the redeclared class error was gone.

Cheers with the community code pool support and automatic module generation. I hope that I'll be able to use do BDD soon.

@jamescowie
Copy link
Member

Thats really strange. Are there any files within Spec already ?
What version of Magento are you using ?

I would like to get to the bottom of this issue as its one that I cant replicate at all. Perhaps we could meet up on Skype or Hangouts when you have 30 mins free to investigate this more.

@maxbaldanza
Copy link
Contributor

Hi @vernard,
I know this is a fairly old PR but by chance were you using an windows environment with magespec?
I've just tried the steps to create the error on the latest version 4.0.0 and can't reproduce but I believe this is may be a windows related looking at the D:\Projects path.
I'm closing in this favour of #155

Feel free to re-open if this is not the case.

@vernard
Copy link
Author

vernard commented Jul 28, 2017

Right, I was on Windows environment.

Thank you for cleaning this repo.

@maxbaldanza
Copy link
Contributor

No problem 👍 sorry for the late reply.
There's a few issues on windows which would be good to get fixed up: https://ci.appveyor.com/project/maxbaldanza/magespec
Happy to accept any PR's if you'd like to contribute towards it 👍

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

No branches or pull requests

3 participants