phpunit

How can I unit test a Joomla 1.5 or 1.6 module with PHPUnit?

纵饮孤独 提交于 2020-01-05 07:41:40
问题 I can not find a tutorial on the subject. Before running the unit test, the Joomla framework must be loaded ... A code example would be welcome, thanks ! 回答1: You might be looking for the official Joomla Unit Testing Documentation - It contains example tests and more stuff to help you getting started. 来源: https://stackoverflow.com/questions/6559553/how-can-i-unit-test-a-joomla-1-5-or-1-6-module-with-phpunit

When to use stubs/mocks and when to use real objects in unit testing?

拈花ヽ惹草 提交于 2020-01-05 07:05:11
问题 I recently tried to improve my unit testing skills and read quite some literature about unit testing and I am also trying to realize what I learned in a php-project I am currently developing with phpunit. But I still have a in my opinion very fundamental question how to unit test methods which interact with objects of other classes or even with other methods of the same class. Is there some rule of thumb or some help how I can decide what dependencies I should stub/mock and for what

How to make assertions on a Laravel Mailable

馋奶兔 提交于 2020-01-05 05:09:27
问题 In a test I would like to make some assertions on a Mailable using Mail::assertSent() , like this: Mail::assertSent(MyMailable::class, function ($mail) use ($user) { return $mail->hasTo($user->email); }); So far, I have found the hasTo() , hasFrom() , hasBcc() and all the other has*() methods work just great. However, when asserting a particular attribute on the Mailable exists, for example subject the attribute shows up as null and the assertion fails: Mail::assertSent(MyMailable::class,

Is a method which composes and executes a CLI command testable?

别来无恙 提交于 2020-01-05 04:39:06
问题 This is the first time I'm getting into unit tests, and I would like to know if there is a way I can test the following method from a simple class. I basically need to check if the command contains certain parameters for each argument passed through the method. The external tool controlled by the command is not returning anything meaningful as far as checking for commands in the returned console output goes. I've read that the body of a method is implementation detail and that it's therefore

Zend Framework 2 Unit Tests on Jenkins not working

谁都会走 提交于 2020-01-05 03:44:09
问题 I have a zend framework 2 project and i am trying to set up my jenkins so that unit tests can be executed. Jenkins is running on ubuntu and i am developing under Windows 7 with PHPStorm. build.xml <target name="phpunit" description="Run unit tests with PHPUnit"> <exec executable="phpunit" failonerror="true"> <arg value="${basedir}/module/Addressbook/test"/> </exec> </target> Folder structure: project module Addressbook test AddressbookTest Controller AddressbookControllerTest.php Boostrap.php

Most efficient way to compare arrays in PHP by order?

一笑奈何 提交于 2020-01-04 13:28:12
问题 Take these two arrays in PHP: $array1 = [ 2 => 'Search', 1 => 'Front-End / GUI' ]; $array2 = [ 1 => 'Front-End / GUI', 2 => 'Search' ]; Most of the array comparison functions do not care about order. Doing an array_diff will result in an empty array. What's the most efficient / shortest / cleanest way to compare two arrays with regard to order and: show whether or not they are equal (true / false)? show the difference (such as for PHPUnit)? Running $this->assertEquals( $array1, $array2 ); in

phpunit selenium usage

别说谁变了你拦得住时间么 提交于 2020-01-04 13:11:36
问题 My question is about phpunit+selenium usage. The standard usage of this union is class BlaBlaTest extends PHPUnit_Extensions_SeleniumTestCase {... } OR class BlaBlaTest extends PHPUnit_Extensions_Selenium2TestCase {...} The first one ( PHPUnit_Extensions_SeleniumTestCase ) is not very convinient to use (e.g. there is no such thing as $this->elements('xpath') ). Second( PHPUnit_Extensions_Selenium2TestCase ) also has limited functionality (e.g. there is no such functions as waitForPageToLoad()

symfony unit tests: add/modify form action

假如想象 提交于 2020-01-04 04:30:09
问题 I have a form, without action (is submitted with javascript) and I'm trying to write a unit test for it, but it fails because "action" attribute is missing: InvalidArgumentException : Current URI must be an absolute URL (""). There is a way to do add it in unit tests or modify the html content using the crawler? <form id="form_search_page"> <input type="text" name="keyword" value="" /> <button type="submit" name="searchBtn" id="searchBtn">Search</button> </form> $client = $this->makeClient

phpunit assertNull gets zend_mm_heap corrupted

送分小仙女□ 提交于 2020-01-04 04:15:16
问题 When using scalar: $null = null; $this->assertNull($null); Test OK $null = 'not null'; $this->assertNull($null); Test Fail When using Object: $this->assertEquals(null, $menu->getChild('Projects')); Test OK or Fail regarding if $menu->getChild('Projects') is null or not $this->assertNull($menu->getChild('Projects')); Hangs and I get the error: zend_mm_heap corrupted When using AssertNull , I do not get the same behavior as AssertEquals(null, $var) ; For the moment, I ban the use of AssertNull,

Yii Fixtures — Exception: Unknown property 'projects' for class 'ProjectTest'

好久不见. 提交于 2020-01-04 02:34:34
问题 I'm following the "Agile web application development with yii 1.1 and php5" book and i'm at the testing with fixtures section. I followed their code but i can't access to the fixture... I'm running my tests with phpunit and it returns me this c:\wamp\www\agileBook\protected\tests>phpunit unit/ProjectTest.php PHPUnit 3.6.11 by Sebastian Bergmann. Configuration read from C:\wamp\www\agileBook\protected\tests\phpunit.xml ←[31;1mE←[0m Time: 0 seconds, Memory: 5.75Mb There was 1 error: 1)