Тестовый класс не указан или недействителенPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Тестовый класс не указан или недействителен

Сообщение Anonymous »

Мне нужно запустить пару тестов консольной команды, каждый из которых будет вносить небольшие изменения в базу данных перед запуском теста. Я структурировал это следующим образом:

Код: Выделить всё

class ActionRemindCommandEmail extends KernelTestCase
{
private $mailCollector;

/**
* @return mixed
*/
public function getMailCollector()
{
return $this->mailCollector;
}

/**
* @param mixed $mailCollector
*/
public function setMailCollector($mailCollector)
{
$this->mailCollector = $mailCollector;
}

protected function setUp()
{
exec('mysql database < prep.sql');
}

public function testExecute()
{
exec('echo "' . str_replace('"', '\\"', $this->getPrepSql() ) . '" | mysql database');

self::bootKernel();
$application = new Application(self::$kernel);

$application->add(new ActionRemindCommand());

$client = static::createClient();
$client->enableProfiler();
$this->setMailCollector($client->getProfile()->getCollector('swiftmailer'));

$command = $application->find('app:ahp:remind');
$commandTester = new CommandTester($command);
$commandTester->execute(array(
'command'  => $command->getName(),
'email' => ''
));
$output = $commandTester->getDisplay();
$this->assertions();
}
}
и первый настоящий тест выглядит так

Код: Выделить всё

    class ActionRemindCommandVetNotifyWhenSavedOnlyTest extends ActionRemindCommandEmailTest
{

protected function getPrepSql()
{
return "INSERT INTO `action` (farmer_id`, `group_id`, `name`, `due`, `active`, `completed`, `notify_vet_email`, `notify_farmer_email`, `notify_vet_text`, `notify_farmer_text`, `notify_tech_text`, `notify_clinic_email`, `notify_farmer_text2`, `notified_vet_email`, `notified_farmer_email`, `notified_clinic_email`, `notified_vet_text`, `notified_farmer_text`, `notified_farmer_text2`, `notified_tech_text`, `notify_vet_email_advance`, `notify_farmer_email_advance`, `notify_clinic_email_advance`, `notify_vet_text_advance`, `notify_farmer_text_advance`, `notify_farmer_text2_advance`, `notify_tech_text_advance`, `no_time`, `notes`, `pending_offline_id`) VALUES "
. " (116, NULL, 'Action 1', '"
. date('Y-m-d H:i:s',mktime(12,0,0,intval(date('n')), intval(date('j'))+14,intval(date('Y'))))
.  "', 1, 0, 1, 0, 0, 0, 0, 0, 0, '000', '000', '000', '000', '000', '000', '000', -1, -1, -1, 24, 24, 24, 24, 0, 'undefined', 'N1478139417184')";

}

public function testExecute()
{
parent::testExecute();
}

protected function assertions()
{
$this->assertEquals(1, $this->getMailCollector()->getMessageCount());
}
}
Настраиваем это в phpstorm с помощью app/phpunit.xml.dist:

Код: Выделить всё



xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="bootstrap.php.cache"
>


../src/*/*Bundle/Tests
../src/*/Bundle/*Bundle/Tests







../src

../src/*/*Bundle/Resources
../src/*/*Bundle/Tests
../src/*/Bundle/*Bundle/Resources
../src/*/Bundle/*Bundle/Tests




Я обнаружил, что не могу выполнить тест, поскольку «класс теста не указан или недействителен»

< img alt="введите описание изображения здесь" src="https://i.sstatic.net/wldgN.png" />

Я пробовал использовать область: class, метод, но я не уверен, чего еще может не хватать?

Подробнее здесь: https://stackoverflow.com/questions/403 ... or-invalid
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»