dongyan1625
2013-09-04 08:44
浏览 67
已采纳

phpunit-skelgen:没有生成测试文件

I try to use phpunit-skelgen

In the doc, it is written

When you are using the skeleton generator to generate code based on a class that is declared in a namespace you have to provide the qualified name of the class as well as the path to the source file it is declared in.

For instance, for a class Calculator that is declared in the project namespace you need to invoke the skeleton generator like this:

phpunit-skelgen --test -- "project\Calculator" Calculator.php PHPUnit Skeleton Generator 1.0.0 by Sebastian Bergmann.

Wrote skeleton for "project\CalculatorTest" to "/home/sb/CalculatorTest.php".

I'm working with symfony 2 My class is like this :

<?php
// src/Acme/SecurityBundle/Security/User/MyUserProvider.php

namespace Acme\SecurityBundle\Security\User;

use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;

use Acme\SecurityBundle\Security\User\MyUser;

class MyUserProvider implements UserProviderInterface
{
    // public functions ...
}

I've tried to run, from my application base directory

phpunit-skelgen --test -- "Acme\SecurityBundle\Security\User\MyUserProvider" "Absolute\Path\to\src\Acme\SecurityBundle\Security\User\MyUserProvider.php"
phpunit-skelgen --test -- "Acme\SecurityBundle\Security\User\MyUserProvider" Absolute\Path\to\src\Acme\SecurityBundle\Security\User\MyUserProvider.php
phpunit-skelgen --test -- Acme\SecurityBundle\Security\User\MyUserProvider Absolute\Path\to\src\Acme\SecurityBundle\Security\User\MyUserProvider.php

even

phpunit-skelgen --test -- "Acme\SecurityBundle\Security\User\MyUserProvider" MyUserProvider.php

and

phpunit-skelgen --test -- MyUserProvider MyUserProvider.php

from Absolute\Path\to\src\Acme\SecurityBundle\Security\User\

phpunit-skelgen --test -- "Acme\SecurityBundle\Security\User\MyUserProvider" MyUserProvider.php

The output is always

PHPUnit Skeleton Generator 1.2.1 by Sebastian Bergmann.

Nothing more. Does anyone has an idea ?

图片转代码服务由CSDN问答提供 功能建议

我尝试使用phpunit-skelgen

在文档中,它是 写入

当您使用骨架生成器基于在命名空间中声明的类生成代码时,您必须提供类的限定名称以及 声明它的源文件的路径。

例如,对于在项目命名空间中声明的类Calculator,您需要调用骨架生成器,如下所示:

phpunit-skelgen --test - “project \ Calculator”Calculator.php 由Sebastian Bergmann编写的PHPUnit Skeleton Generator 1.0.0。

为“ project \ CalculatorTest“to”/home/sb/CalculatorTest.php".

nn

我正在使用symfony 2 我的课程是这样的:

 &lt;?php 
 // src / Acme / SecurityBundle / Security / User / MyUserProvider.php 
 
namespace Acme \ SecurityBundle \ Security \ User; 
 
use Symfony \ 组件\安全\核心\用户\ UserProvide  rInterface; 
use Symfony \ Component \ Security \ Core \ User \ UserInterface; 
use Symfony \ Component \ Security \ Core \ Exception \ UsernameNotFoundException; 
use Symfony \ Component \ Security \ Core \ Exception \ UnsupportedUserException; 
 
use Acme \  SecurityBundle \ Security \ User \ MyUser; 
 
class MyUserProvider实现UserProviderInterface 
 {
 //公共函数... 
} 
   
 
 

我已经 试图从我的应用程序基目录运行

  phpunit-skelgen --test  - “Acme \ SecurityBundle \ Security \ User \ MyUserProvider”“Absolute \ Path \ to \ src  \ Acme \ SecurityBundle \ Security \ User \ MyUserProvider.php“
 
nphpunit-skelgen --test  - ”Acme \ SecurityBundle \ Security \ User \ MyUserProvider“Absolute \ Path \ to \ src \ Acme \ SecurityBundle \ Security \ User \ MyUserProvider  .php 
phpunit-skelgen --test  -  Acme \ SecurityBundle \ Security \ User \ MyUserProvider Absolute \ Path \ to \ src \ Acme \ SecurityBundle \ Security \ User \ MyUserProvider.php 
   \  n 
 

甚至

  phpunit-skelgen --test  - “Acme \ SecurityBundle \ Secu  rity \ User \ MyUserProvider“MyUserProvider.php 
   
 
 

  phpunit-skelgen --test  -  MyUserProvider  MyUserProvider.php 
   
 
 

从Absolute \ Path \到\ src \ Acme \ SecurityBundle \ Security \ User \

  phpunit-skelgen --test  - “Acme \ SecurityBundle \ Security \ User \ MyUserProvider”MyUserProvider.php 
   
 
 

输出始终为 <前> PHPUnit Skeleton Generator 1.2.1 by Sebastian Bergmann。

仅此而已。 是否有人有想法? \ n

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongsan6889 2013-09-05 13:53
    已采纳

    I simply forgot the bootstrap

    phpunit-skelgen --bootstrap app\bootstrap.php.cache --test -- "Acme\SecurityBundle\Security\User\MyUserProvider" "E:\path\to\app\src\Acme\SecurityBundle\Security\User\MyUserProvider.php"
    
    打赏 评论

相关推荐 更多相似问题