public function testShowThingsUp() { $strategy = $this->prophesize("Bench\\IterationStrategy"); $strategy->getIterateCount(Argument::Any(), Argument::Any())->willReturn(10); $b = new B("test", $strategy->reveal()); $printer = new PrintResult($b); $this->assertRegExp("/test[ ]*\\d+[ ]*\\d+\\.\\d+ (ms|us|s){1}\\/op/i", (string) $printer); }
public function it_should_execute_the_action_and_before_steps_for_methods(ContainerInterface $container, HookReader $reader, Request $request, Response $response, Index $controller) { $container->get("Corley\\Demo\\Controller\\Index")->willReturn($controller); $reader->getMethodAnnotationsFor(Argument::Any(), "index", Before::class)->willReturn([(object) ["targetClass" => "Corley\\Demo\\Controller\\Index", "targetMethod" => "far"]]); $reader->getMethodAnnotationsFor(Argument::Any(), Argument::Any(), Argument::Any())->willReturn([]); $reader->getClassAnnotationsFor(Argument::Any(), Argument::Any())->willReturn([]); $controller->index($request, $response, Argument::Any())->shouldBeCalledTimes(1); $controller->far($request, $response, Argument::Any())->shouldBeCalledTimes(1); $matched = ["controller" => "Corley\\Demo\\Controller\\Index", "action" => "index"]; $this->execute($request, $response, $matched); }
function it_gets_available_updates($client) { $fakeResponse = '{"_items":{"core":[{"version":"0.2.1","changelog":["commit1"]},{"version":"0.2.0"}]}}'; $client->call(Argument::Any(), Argument::Type('array'))->willReturn($fakeResponse); $result = $this->getAvailableUpdates(); $result->shouldHaveCount(1); $result->shouldBeArray(); foreach ($result['core'] as $package) { $package->shouldHaveType('SWP\\UpdaterBundle\\Model\\UpdatePackage'); } }
public function testRunBenchmarks() { $strategy = $this->prophesize("Bench\\IterationStrategy"); $strategy->getIterateCount(Argument::Any(), Argument::Any())->willReturn(10); $extractor = $this->prophesize("Bench\\MethodExtractor"); $extractor->getCallables()->willReturn([["test", function () { }]]); $output = $this->prophesize('Symfony\\Component\\Console\\Output\\OutputInterface'); $output->writeln(Argument::Any())->shouldBeCalledTimes(1); $sut = new BenchRunner($extractor->reveal(), $strategy->reveal(), $output->reveal()); $sut->runBenchmarks(new PrintResult()); }
function it_creates_pending_version($versionFactory, ProductInterface $product, Version $pending) { $product->getId()->willReturn(1); $versionFactory->create(Argument::Any(), 1, 'baz', null)->willReturn($pending); $pending->getChangeset()->willReturn($pending); $pending->setChangeset([])->willReturn($pending); $pending->getAuthor()->willReturn('baz'); $pending->isPending()->willReturn(true); $version = $this->createPendingVersion($product, 'baz', []); $version->shouldBeAnInstanceOf('Pim\\Bundle\\VersioningBundle\\Model\\Version'); $version->getAuthor()->shouldReturn('baz'); $version->isPending()->shouldReturn(true); }
function it_should_compose_the_deb(Parser $parser, Packager $packager, StandardFile $control) { $packager->run()->willReturn($packager); $packager->build()->willReturn("dpkg -b something.deb"); $packager->getControl()->willReturn($control); $packager->setOutputPath("/path/to/out")->shouldBeCalledTimes(1); $packager->mount("/here", "/mnt/one")->shouldBeCalledTimes(1); $packager->mount("/here2", "/mnt/two")->shouldBeCalledTimes(1); $control->offsetSet("Package-Name", "my-package-name")->shouldBeCalledTimes(1); $control->offsetSet("Version", "0.0.1")->shouldBeCalledTimes(1); $yml = ["output_path" => "/path/to/out", "control" => ["package_name" => "my-package-name", "version" => "0.0.1"], "mount" => [["src" => "/here", "dest" => "/mnt/one"], ["src" => "/here2", "dest" => "/mnt/two"]]]; $parser->parse(Argument::Any())->willReturn($yml); $this->compose("parser is mocked out")->shouldReturn("dpkg -b something.deb"); }
public function testCalibration() { $strategy = $this->prophesize("Bench\\IterationStrategy"); $strategy->getIterateCount(Argument::Any(), Argument::Any())->willReturn(10); $b = new B("test", $strategy->reveal()); $b->times(); usleep(1000.0); $b->times(); $actualDuration = $b->getDuration(); $calibration = new B("Calibration", $strategy->reveal()); $calibration->times(); usleep(100.0); $calibration->times(); $b->calibrateWith($calibration); $this->assertLessThan($actualDuration, $b->getDuration()); }
public function testUpdate() { $response = $this->dummy_response(); $api = $this->prophet->prophesize('\\Push_API\\API'); $api->update_article("123", "456", Argument::Any(), array())->willReturn($response)->shouldBeCalled(); // Create post, simulate that the post has been synced $post_id = $this->factory->post->create(); update_post_meta($post_id, 'apple_export_api_id', 123); update_post_meta($post_id, 'apple_export_api_revision', 456); $action = new Push($this->settings, $post_id); $action->set_api($api->reveal()); $action->perform(); $this->assertEquals($response->data->id, get_post_meta($post_id, 'apple_export_api_id', true)); $this->assertEquals($response->data->createdAt, get_post_meta($post_id, 'apple_export_api_created_at', true)); $this->assertEquals($response->data->modifiedAt, get_post_meta($post_id, 'apple_export_api_modified_at', true)); $this->assertEquals($response->data->shareUrl, get_post_meta($post_id, 'apple_export_api_share_url', true)); $this->assertEquals(null, get_post_meta($post_id, 'apple_export_api_deleted', true)); }
function it_creates_a_version_on_object_deletion($versionFactory, $versionRepository, $tokenStorage, $authorizationChecker, $versionSaver, Version $previousVersion, Version $removeVersion, TokenInterface $token, UserInterface $admin, VersionableInterface $price, RemoveEvent $event) { $tokenStorage->getToken()->willReturn($token); $token->getUser()->willReturn($admin); $admin->getUsername()->willReturn('admin'); $authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')->willReturn(true); $versionRepository->getNewestLogEntry(Argument::any(), 12)->willReturn($previousVersion); $previousVersion->getVersion()->willReturn(11); $previousVersion->getSnapshot()->willReturn(['foo' => 'bar']); $versionFactory->create(Argument::Any(), 12, 'admin', 'Deleted')->willReturn($removeVersion); $removeVersion->setVersion(12)->willReturn($removeVersion); $removeVersion->setSnapshot(['foo' => 'bar'])->willReturn($removeVersion); $removeVersion->setChangeset([])->willReturn($removeVersion); $versionSaver->save($removeVersion)->shouldBeCalled(); $event->getSubject()->willReturn($price); $event->getSubjectId()->willReturn(12); $this->postRemove($event); }
public function it_register_service_command_resolver(Container $container) { $container->offsetSet('command.resolver', Argument::Any())->shouldBeCalled(); $this->register($container); }
function it_should_capture_any_kind_of_error_as_internal_server_error(UrlMatcher $matcher, AnnotExecutor $executor, Request $request, Response $response) { $matcher->matchRequest(Argument::Any())->willThrow("Exception"); $response->setStatusCode(500)->shouldBeCalled(); $this->run($request, $response)->shouldBe($response); }
public function it_should_trigger_the_mark_it_event_during_the_far_call(EventManager $eventManager) { $eventManager->trigger("mark-it", Argument::Any())->shouldBeCalledTimes(1); $this->far(); }
public function testTagsFieldIsMergedWithGlobalTags() { $options = new Options(); $options->setDatabase("db"); $options->setTags(["dc" => "us-west"]); $httpClient = $this->prophesize("GuzzleHttp\\Client"); $httpClient->post(Argument::Any(), ["auth" => ["root", "root"], "query" => ["db" => "db", "retentionPolicy" => "default"], "body" => 'tcp.test,dc=us-west,region=us mark="element" 1257894000000000000'])->shouldBeCalledTimes(1); $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); $adapter->send(["time" => "2009-11-10T23:00:00Z", "tags" => ["region" => "us"], "points" => [["measurement" => "tcp.test", "fields" => ["mark" => "element"]]]]); }
function its_method_get_package_should_return_a_package($client) { $client->makeApiCall(Argument::Any(), null, null)->willReturn('{ "version": "v1", "associations": { "mainpic": { "type": "picture", "uri": "http://publicapi:5050/items/tag%3Ademodata.org%2C0001%3Aninjs_XYZ123" }, "storyText": { "type": "text", "uri": "http://publicapi:5050/items/tag%3Ademodata.org%2C0003%3Aninjs_XYZ123" } }, "person": [ { "name": "Hulk Hogan", "rel": "author" }, { "name": "The Phototaker", "rel": "photographer" } ], "_links": { "parent": { "title": "home", "href": "/" }, "collection": { "title": "packages", "href": "packages" }, "self": { "title": "Package", "href": "packages/tag:demodata.org,0012:ninjs_XYZ123" } }, "body_text": "Want to try McRide or McGhostHouse?", "profile": "text-photo", "copyrightnotice": "Free to use for everyone", "pubstatus": "usable", "language": "en", "type": "composite", "located": "Bilbao city center, Spain", "subject": [ { "name": "Business", "rel": "about" }, { "name": "Economy", "rel": "about" }, { "name": "Entertainment", "rel": "about" } ], "urgency": 8, "uri": "http://publicapi:5050/packages/tag%3Ademodata.org%2C0012%3Aninjs_XYZ123", "headline": "McDonalds opens its own theme park", "versioncreated": "2014-08-15T11:33:42+0000", "body_html": "<p>Want to try <em>McRide</em> or <em>McGhostHouse</em>?</p>", "byline": "Hulk Hogan, The Undertaker", "place": [ { "name": "Bilbao" }, { "name": "Spain" } ] }'); $this->getPackage(Argument::any())->shouldReturnAnInstanceOf('Superdesk\\ContentApiSdk\\Data\\Package'); }
private function prepareDns($values) { $dns = $this->prophesize("Corley\\Service\\Dns"); $dns->resolve(Argument::Any())->willReturn($values); return $dns->reveal(); }
public function testFetchNumberedColumn() { $client = $this->prophesize("InfluxDB\\Client"); $client->query(Argument::Any())->willReturn(json_decode(<<<EOF { "results": [ { "series": [ { "name": "cpu_load_short", "tags": { "host": "server01", "region": "us-west" }, "columns": [ "time", "value" ], "values": [ [ "2015-06-11T20:46:02Z", 0.64 ], [ "2015-06-12T02:19:22Z", 0.54 ], [ "2015-06-12T05:06:02Z", 0.92 ] ] } ] } ] } EOF , true)); $stmt = new InfluxDBStatement($client->reveal(), "SELECT * FROM cpu"); $stmt->execute(); $this->assertEquals(0.64, $stmt->fetchColumn(1)); $this->assertEquals(0.54, $stmt->fetchColumn("value")); }