示例#1
0
 public function testUnsettingChildrenRestoresContentType()
 {
     $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false);
     $child = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE);
     $cType->shouldReceive('setFieldBodyModel')->twice()->with('image/jpeg');
     $cType->shouldReceive('setFieldBodyModel')->once()->with('multipart/alternative');
     $cType->shouldReceive('setFieldBodyModel')->zeroOrMoreTimes()->with(\Mockery::not('multipart/alternative', 'image/jpeg'));
     $entity = $this->_createEntity($this->_createHeaderSet(array('Content-Type' => $cType)), $this->_createEncoder(), $this->_createCache());
     $entity->setContentType('image/jpeg');
     $entity->setChildren(array($child));
     $entity->setChildren(array());
 }
 /**
  * @expectedException \Mockery\Exception
  */
 public function testNotConstraintThrowsExceptionWhenConstraintUnmatched()
 {
     $this->mock->shouldReceive('foo')->with(Mockery::not(2))->once();
     $this->mock->foo(2);
     $this->container->mockery_verify();
 }
 /**
  * Test description.
  *
  * @return void
  */
 public function testRunWithCoverage()
 {
     $expected_coverage = array('test1' => 'test2');
     $remote_coverage_helper = m::mock('aik099\\PHPUnit\\RemoteCoverage\\RemoteCoverageHelper');
     $remote_coverage_helper->shouldReceive('get')->with('some-url', 'tests\\aik099\\PHPUnit\\Fixture\\WithoutBrowserConfig__getTestId')->andReturn($expected_coverage);
     /* @var $test_case BrowserTestCase */
     /* @var $session_strategy ISessionStrategy */
     list($test_case, $session_strategy) = $this->prepareForRun();
     $test_case->setName('getTestId');
     $test_case->setRemoteCoverageHelper($remote_coverage_helper);
     $test_case->setRemoteCoverageScriptUrl('some-url');
     $code_coverage = m::mock('\\PHP_CodeCoverage');
     $code_coverage->shouldReceive('append')->with($expected_coverage, $test_case)->once();
     $result = $this->getTestResult($test_case, 1, true);
     $result->shouldReceive('getCodeCoverage')->once()->andReturn($code_coverage);
     $test_id = $test_case->getTestId();
     $this->assertEmpty($test_id);
     $browser = $test_case->getBrowser();
     $browser->shouldReceive('getBaseUrl')->once()->andReturn('A');
     $session = m::mock('\\Behat\\Mink\\Session');
     $session->shouldReceive('visit')->with('A')->once();
     $session->shouldReceive('setCookie')->with(RemoteCoverageTool::TEST_ID_VARIABLE, null)->once();
     $session->shouldReceive('setCookie')->with(RemoteCoverageTool::TEST_ID_VARIABLE, m::not(''))->once();
     $session_strategy->shouldReceive('session')->once()->andReturn($session);
     $test_case->run($result);
     $this->assertNotEmpty($test_case->getTestId());
 }