private function _initMockClientFactory()
 {
     $prophet = new \Prophecy\Prophet();
     $client = $prophet->prophesize("Bxav\\Bundle\\ServiceHandlerClientBundle\\Model\\SoapClient");
     $client->getFunctions()->willReturn([]);
     $this->clientFactory->get(Argument::any())->willReturn($client);
 }
 /**
  * Create a dummy variable for a User
  * @return User the dummy variable
  */
 protected function getUser()
 {
     $prophet = new \Prophecy\Prophet();
     $prophecy = $prophet->prophesize();
     $prophecy->willImplement(User::class);
     return $prophecy->reveal();
 }
 /**
  *
  * @author Lionel Lecaque, lionel@taotesting.com
  * @param string $uri            
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 private function getResourceMock($uri)
 {
     $prophet = new \Prophecy\Prophet();
     $resource = $prophet->prophesize('core_kernel_classes_Resource');
     $resource->getUri()->willReturn($uri);
     return $resource;
 }
 /**
  *
  * @author Lionel Lecaque, lionel@taotesting.com
  */
 public function testSet()
 {
     $prophet = new \Prophecy\Prophet();
     $hookProphecy = $prophet->prophesize('oat\\taoQtiItem\\model\\Hook');
     $hook = $hookProphecy->reveal();
     HookRegistry::getRegistry()->set('fakeInteraction', get_class($hook));
     $interactions = HookRegistry::getRegistry()->getMap();
     $this->assertEquals(get_class($hook), $interactions['fakeInteraction']);
 }
 function getConfig()
 {
     $prophet = new Prophecy\Prophet();
     $iframe_listener = $prophet->prophesize('Pesapal\\Contracts\\IFrameListener');
     $ipn_listener = $prophet->prophesize('Pesapal\\Contracts\\PaymentListener');
     $faker = \Faker\Factory::create();
     $credentials = new \Pesapal\Values\Credentials($faker->word, $faker->word);
     $demoStatus = new \Pesapal\Values\DemoStatus(true);
     $iframe_listeners = [$iframe_listener->reveal()];
     $ipn_listeners = [$ipn_listener->reveal()];
     $callback_url = "";
     $config = new \Pesapal\Config($credentials, $demoStatus, $iframe_listeners, $ipn_listeners, $callback_url);
     return $config;
 }
Example #6
0
 public function testFlushWithFlushableDelegate()
 {
     $prophet = new \Prophecy\Prophet();
     $prophecy = $prophet->prophesize();
     $prophecy->willExtend('stdClass');
     $prophecy->willImplement('Ddeboer\\DataImport\\Writer');
     $prophecy->willImplement('Ddeboer\\DataImport\\Writer\\FlushableWriter');
     $prophecy->writeItem(\Prophecy\Argument::any())->shouldBeCalledTimes(40);
     $prophecy->prepare()->shouldBeCalledTimes(2);
     $prophecy->flush()->shouldBeCalled();
     $writer = new BatchWriter($prophecy->reveal());
     $writer->prepare();
     for ($i = 0; $i < 40; $i++) {
         $writer->writeItem(['Test']);
     }
 }
 /**
  * 
  * @param string $locale
  * @param string $fallbackLocale
  * @return TranslatableStringHelper
  */
 protected function getTranslatableStringHelper($locale = 'en', $fallbackLocale = 'en')
 {
     $prophet = new \Prophecy\Prophet();
     $requestStack = $prophet->prophesize();
     $request = $prophet->prophesize();
     $translator = $prophet->prophesize();
     $request->willExtend('Symfony\\Component\\HttpFoundation\\Request');
     $request->getLocale()->willReturn($fallbackLocale);
     $requestStack->willExtend('Symfony\\Component\\HttpFoundation\\RequestStack');
     $requestStack->getCurrentRequest()->will(function () use($request) {
         return $request;
     });
     $translator->willExtend('Symfony\\Component\\Translation\\Translator');
     $translator->getFallbackLocales()->willReturn($locale);
     return new TranslatableStringHelper($requestStack->reveal(), $translator->reveal());
 }
 private function getDeliveryExecution()
 {
     $id = 'http://sample/first.rdf#i1450190828500474_test_record';
     $prophet = new \Prophecy\Prophet();
     $deliveryExecutionProphecy = $prophet->prophesize(DeliveryExecution::class);
     $deliveryExecutionProphecy->getIdentifier()->willReturn($id);
     return $deliveryExecutionProphecy->reveal();
 }
 /**
  *
  * @author Lionel Lecaque, lionel@taotesting.com
  */
 public function testStoreTestVariable()
 {
     //init the resultserver
     $this->service->initResultServer('http://www.tao.lu/Ontologies/TAOResultServer.rdf#void');
     $this->service->spawnResult('testcase_deliveryexecId', 'testcase_deliveryresultId');
     $prophet = new \Prophecy\Prophet();
     $prophecy = $prophet->prophesize();
     $prophecy->willExtend('taoResultServer_models_classes_Variable');
     $variable = $prophecy->reveal();
     $res = $this->service->storeTestVariable(null, $variable, null);
     $this->assertEquals('testcase_deliveryresultId', $res);
 }
 protected function getDeliveryExecution($id = null)
 {
     if ($id === null) {
         $id = $this->deliveryExecutionId;
     }
     $prophet = new \Prophecy\Prophet();
     $deliveryExecutionProphecy = $prophet->prophesize('oat\\taoDelivery\\models\\classes\\execution\\DeliveryExecution');
     $deliveryExecutionProphecy->getIdentifier()->willReturn($id);
     return $deliveryExecutionProphecy->reveal();
 }
Example #11
0
 /**
  * @test
  */
 protected static function createForThisClassTest()
 {
     $prophet = new \Prophecy\Prophet();
     /** @var ClassLoader $dummy */
     $dummy = $prophet->prophesize(ClassLoader::class)->reveal();
     /** @var CodeExtractor $codeExtractor */
     $codeExtractor = $prophet->prophesize(CodeExtractor::class)->reveal();
     $provider = new static($dummy, $codeExtractor);
     $definitions = $provider->createForClasses([__CLASS__ => new File(__FILE__)]);
     test_flight_assert(key($definitions) === __CLASS__);
     test_flight_assert(is_array($definitions[__CLASS__]));
     test_flight_assert(current($definitions[__CLASS__]) instanceof \Cundd\TestFlight\Definition\AbstractMethodDefinition);
     test_flight_assert(current($definitions[__CLASS__]) instanceof \Cundd\TestFlight\Definition\StaticMethodDefinition);
     test_flight_throws(function () use($provider) {
         $provider->createForClasses(['NotExistingClass' => new File(__FILE__)]);
     }, \ReflectionException::class);
 }
Example #12
0
 public function testProphesize()
 {
     $this->skip('Waiting for this issue to be fixed: https://github.com/phpspec/prophecy/issues/233');
     $this->given($prophecy = $this->prophet('Prophecy\\Prophecy\\ObjectProphecy')->reveal(), $prophet = $this->prophet('Prophecy\\Prophet'), $prophet->prophesize($class = uniqid())->willReturn($prophecy)->shouldBeCalled, $p = new \Prophecy\Prophet(), $prophetProphecy = $p->prophesize('Prophecy\\Prophet'), $objectProphecy = $p->prophesize('Prophecy\\Prophecy\\ObjectProphecy'), $prophetProphecy->prophesize($class)->willReturn($objectProphecy->reveal()))->dump($prophetProphecy->reveal()->prophesize($class))->when($this->newTestedInstance(null, null, null, $prophet))->then->object($this->testedInstance->prophesize($class))->isInstanceOf('mageekguy\\atoum\\prophecy\\asserters\\prophet\\object')->and->prophet->checkPredictions;
 }
Example #13
0
 /**
  * Prophecy initialization
  */
 private function initProphecy()
 {
     $prophet = new \Prophecy\Prophet();
     $this->prophecy = $prophet->prophesize($this->classname);
     $this->initProphecyReturnValues();
 }
Example #14
0
 /**
  * @test
  */
 protected static function printExceptionTest()
 {
     $prophet = new \Prophecy\Prophet();
     /** @var WindowHelper $windowHelper */
     $windowHelper = $prophet->prophesize(WindowHelper::class)->reveal();
     /** @var CodeFormatter $codeFormatter */
     $codeFormatter = $prophet->prophesize(CodeFormatter::class)->reveal();
     /** @var MethodDefinition $testDefinition */
     /** @var MethodDefinition|\Prophecy\Prophecy\ObjectProphecy $prophecy */
     $prophecy = $prophet->prophesize(MethodDefinition::class);
     $prophecy->getClassName()->willReturn(__CLASS__);
     $prophecy->getMethodIsStatic()->willReturn(false);
     $prophecy->getMethodName()->willReturn('thisIsTheDummyTestMethodForTheTest');
     $prophecy->getFilePath()->willReturn(__FILE__);
     $testDefinition = $prophecy->reveal();
     $tempOutputStream = fopen('php://memory', 'r+');
     $printer = new static($tempOutputStream, $tempOutputStream, $windowHelper, $codeFormatter);
     $printer->setEnableColoredOutput(false);
     $printer->printException($testDefinition, new \Exception('ExceptionMessage'));
     rewind($tempOutputStream);
     $output = stream_get_contents($tempOutputStream);
     $testString = "\n" . 'Error Exception #0 during test ' . 'Cundd\\TestFlight\\Output\\ExceptionPrinter->thisIsTheDummyTestMethodForTheTest(): ' . "\n" . 'ExceptionMessage';
     test_flight_assert_same($testString, substr($output, 0, strlen($testString)));
 }
 private function _initMockServiceFactory()
 {
     $prophet = new \Prophecy\Prophet();
     $service = $prophet->prophesize("Bxav\\Bundle\\ServiceHandlerClientBundle\\Model\\SoapService");
     $this->serviceFactory->create(Argument::any())->willReturn($service);
 }
Example #16
0
 private function mockStatementFor($pdo, $query)
 {
     $prophet = new \Prophecy\Prophet();
     $statement = $prophet->prophesize();
     $statement->willExtend('PDOStatement');
     $statement->execute()->willReturn(null);
     $statement->closeCursor()->willReturn(null);
     $pdo->prepare($query)->shouldBeCalled()->willReturn($statement);
     return $statement;
 }