Example #1
0
 /**
  * Static shortcut to closing up and verifying all mocks in the global
  * container, and resetting the container static variable to null
  *
  * @return void
  */
 public static function close()
 {
     if (is_null(self::$_container)) {
         return;
     }
     self::$_container->mockery_teardown();
     self::$_container->mockery_close();
     self::$_container = null;
 }
Example #2
0
 public function testShouldIgnoreMissingCallingNonExistentMethods()
 {
     Mockery::getConfiguration()->allowMockingNonExistentMethods(true);
     $mock = $this->container->mock('ClassWithMethods')->shouldIgnoreMissing();
     assertThat(nullValue($mock->foo()));
     assertThat(nullValue($mock->bar()));
     assertThat(nullValue($mock->nonExistentMethod()));
     $mock->shouldReceive(array('foo' => 'new_foo', 'nonExistentMethod' => 'result'));
     $mock->shouldReceive('bar')->passthru();
     assertThat($mock->foo(), equalTo('new_foo'));
     assertThat($mock->bar(), equalTo('bar'));
     assertThat($mock->nonExistentMethod(), equalTo('result'));
 }
Example #3
0
 /**
  * Static fetching of a mock associated with a name or explicit class poser
  */
 public static function fetchMock($name)
 {
     return self::$_container->fetchMock($name);
 }
 /**
  * @test
  */
 public function itShouldAllowNullableClassToBeNull()
 {
     $mock = $this->container->mock("test\\Mockery\\Fixtures\\MethodWithNullableReturnType");
     $mock->shouldReceive('nullableClass')->andReturn(null);
     $mock->nullableClass();
 }