Author: Sebastian Bergmann (sebastian@phpunit.de)
Inheritance: extends PHPUnit_Framework_Constraint
Exemple #1
0
 /**
  * @covers Jam_Query_Builder_Insert::__call
  */
 public function test_call()
 {
     $mock = $this->getMock('stdClass', array('test_event_callback'));
     $jam_event_data_constraint = new PHPUnit_Framework_Constraint_And();
     $jam_event_data_constraint->setConstraints(array($this->isInstanceOf('Jam_Event_Data'), $this->attribute($this->equalTo('builder.call_custom'), 'event'), $this->attribute($this->isInstanceOf('Jam_Query_Builder_Insert'), 'sender'), $this->attribute($this->equalTo(array('abc')), 'args')));
     $mock->expects($this->once())->method('test_event_callback')->with($this->isInstanceOf('Jam_Query_Builder_Insert'), $jam_event_data_constraint, $this->equalTo('abc'));
     Jam::meta('test_author')->events()->bind('builder.call_custom', array($mock, 'test_event_callback'));
     $insert = new Jam_Query_Builder_Insert('test_author');
     $insert->custom('abc');
 }
 public function testGetExtendedElement()
 {
     $switchAttributeCode = 'test_code';
     $form = $this->getMockBuilder(\Magento\Framework\Data\Form::class)->disableOriginalConstructor()->getMock();
     $and = new \PHPUnit_Framework_Constraint_And();
     $and->setConstraints([new \PHPUnit_Framework_Constraint_ArrayHasKey('value')]);
     $form->expects($this->once())->method('addField')->with($switchAttributeCode, 'select', $and);
     $this->formFactory->expects($this->once())->method('create')->with()->will($this->returnValue($form));
     $product = $this->getProduct();
     $product->expects($this->once())->method('getData')->with($switchAttributeCode)->will($this->returnValue(123));
     $this->object->setIsDisabledField(true);
     $this->object->getExtendedElement($switchAttributeCode);
 }
 /**
  * Logical AND.
  *
  * @return PHPUnit_Framework_Constraint_And
  * @access public
  * @since  Method available since Release 3.0.0
  * @static
  */
 public static function logicalAnd()
 {
     $constraints = func_get_args();
     $constraint = new PHPUnit_Framework_Constraint_And();
     $constraint->setConstraints($constraints);
     return $constraint;
 }
 /**
  * Assert that layout block is placed after all expected ones
  *
  * @param string $blockName
  * @param array $after
  * @param string $message
  */
 public static function assertLayoutBlockBeforeAll($blockName, array $before, $message = '')
 {
     $constaints = array();
     foreach ($before as $value) {
         $constaints[] = self::layoutBlock($blockName, EcomDev_PHPUnit_Constraint_Layout_Block::TYPE_BEFORE, $value);
     }
     $logicalAnd = new PHPUnit_Framework_Constraint_And();
     $logicalAnd->setConstraints($constaints);
     self::assertThatLayout($logicalAnd, $message);
 }