Функция метода at () была удалена из PhpUnit 10 позже.
Я изменил AT () на one () , но мои тесты все еще не проходят
Тест не удается, потому что вы не можете упорядочить вызовы условия ().
Функция метода [b] at () [/b] была удалена из PhpUnit 10 позже. Я изменил AT () на [b] one () [/b], но мои тесты все еще не проходят Тест не удается, потому что вы не можете упорядочить вызовы условия ().[code]... /** * KernelEvents::REQUEST => 'onRequest' */ public function onRequest(RequestEvent $event) { ... $termStorage = $this->entityTypeManager->getStorage('taxonomy_term'); $query = $termStorage->getQuery() ->condition('vid', $vocabulary_id) ->condition('name', $name); $termIds = $query->execute(); .... ... < /code> код Unittest: < /p> ... public function testOnRequest() { ... $query = $this->createMock(QueryInterface::class); $query->expects($this->once()) ->method('condition') ->with('vid', 'test_tags') ->willReturnSelf(); $query->expects($this->once()) ->method('condition') ->with('name', 'Existing Tag') ->willReturnSelf(); $query->expects($this->once()) ->method('execute') ->willReturn([123]);
$this->entityTypeManager->expects($this->once()) ->method('getStorage') ->with('taxonomy_term') ->willReturn($termStorage); ... } ... < /code> запустить phpunit: < /p> ... Expectation failed for method name is "condition" when invoked 1 time Parameter 0 for invocation Drupal\Core\Entity\Query\QueryInterface::condition('vid', 'test_tags', null, null) does not match expected value. Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'name' +'vid' ... [/code] Как мне написать тестовый код?