public function doRun(InputInterface $input, OutputInterface $output) { $password = getenv('VAULT_PASSWORD'); $tries = 0; while (!$password) { $question = new Question('Vault password: '******'question'); $password = $helper->ask($input, $output, $question); } $this->vault = new Vault($password, $output); // Defaults $this->vault->setStoragePath(getcwd() . '/vault'); $this->vault->setWorkPath(getcwd() . '/secure'); $this->vault->verify(); // Load droid.yml $filename = $this->getVaultFilename(); if ($filename && file_exists($filename)) { $loader = new JsonLoader(); $loader->load($vault, $filename); } else { } return parent::doRun($input, $output); }
public function testGetLibraryFile() { $curlResponse = CurlResponse::create(JsonLoader::getLibraryFileJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('get')->with()->will($this->returnValue($curlResponse)); $response = $this->libraryService->getLibraryFile("accessToken", "4"); $this->assertInstanceOf('Ctct\\Components\\Library\\File', $response); $this->assertEquals("IMG_0261.JPG", $response->name); $this->assertEquals("4", $response->id); $this->assertEquals("chocolates", $response->description); $this->assertEquals("Images", $response->folder); $this->assertEquals(600, $response->height); $this->assertEquals(800, $response->width); $this->assertEquals(68825, $response->size); $this->assertEquals("https://origin.ih.l1.constantcontact.com/fs115/1100310339939/img/4.jpg", $response->url); $this->assertEquals("MyComputer", $response->source); $this->assertEquals("Active", $response->status); $this->assertInstanceOf('Ctct\\Components\\Library\\Thumbnail', $response->thumbnail); $this->assertEquals("https://origin.ih.l1.constantcontact.com/fs115/1100310339939/img/4.jpg", $response->thumbnail->url); $this->assertEquals(200, $response->thumbnail->width); $this->assertEquals(150, $response->thumbnail->height); $this->assertEquals("2013-06-19T11:36:43.000-04:00", $response->created_date); $this->assertEquals("2013-08-23T12:54:17.000-04:00", $response->modified_date); $this->assertEquals(null, $response->folder_id); $this->assertEquals(true, $response->is_image); $this->assertEquals("JPG", $response->type); }
public static function setUpBeforeClass() { self::$client = new Client(); $addPreAlertStream = Stream::factory(JsonLoader::getAddPreAlert()); $mock = new Mock([new Response(200, array(), $addPreAlertStream)]); self::$client->getEmitter()->attach($mock); }
public static function setUpBeforeClass() { self::$client = new Client(); $tokenInfoStream = Stream::factory(JsonLoader::getTokenInfoJson()); $accessTokenStream = Stream::factory(JsonLoader::getAccessTokenJson()); $mock = new Mock([new Response(200, array(), $tokenInfoStream), new Response(200, array(), $accessTokenStream)]); self::$client->getEmitter()->attach($mock); }
public static function setUpBeforeClass() { self::$client = new Client(); $verifiedAddressStream = Stream::factory(JsonLoader::getVerifiedAddressesJson()); $accountInfoStream = Stream::factory(JsonLoader::getAccountInfoJson()); $mock = new Mock([new Response(200, array(), $verifiedAddressStream), new Response(200, array(), $accountInfoStream)]); self::$client->getEmitter()->attach($mock); }
public static function setUpBeforeClass() { self::$client = new Client(); $getWareHouses = Stream::factory(JsonLoader::getWareHouse()); $mock = new Mock([new Response(200, array(), $getWareHouses)]); self::$client->getEmitter()->attach($mock); self::$transRush = new \TransRush\TransRush(['Token' => '3E3CB737-FD2E-4699-9E25-66ADA387C37A', 'Env' => 'DEV', 'Key' => 'CD88153912AG']); }
public static function setUpBeforeClass() { self::$client = new Client(); $getListsStream = Stream::factory(JsonLoader::getListsJson()); $getListStream = Stream::factory(JsonLoader::getListJson()); $getContactsStream = Stream::factory(JsonLoader::getContactsJson()); $mock = new Mock([new Response(200, array(), $getListsStream), new Response(200, array(), $getListStream), new Response(201, array(), $getListStream), new Response(200, array(), $getListStream), new Response(200, array(), $getContactsStream)]); self::$client->getEmitter()->attach($mock); }
public static function setUpBeforeClass() { self::$client = new Client(); $getCampaignsStream = Stream::factory(JsonLoader::getCampaignsJson()); $getCampaignStream = Stream::factory(JsonLoader::getCampaignJson()); $getPreviewStream = Stream::factory(JsonLoader::getPreviewJson()); $mock = new Mock([new Response(200, array(), $getCampaignsStream), new Response(204, array()), new Response(400, array()), new Response(200, array(), $getCampaignStream), new Response(201, array(), $getCampaignStream), new Response(200, array(), $getCampaignStream), new Response(200, array(), $getPreviewStream)]); self::$client->getEmitter()->attach($mock); }
public function testGetVerifiedAddresses() { $curlResponse = CurlResponse::create(JsonLoader::getVerifiedAddressesJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('get')->with()->will($this->returnValue($curlResponse)); $response = $this->accountService->getVerifiedEmailAddresses("accessToken", array()); $this->assertInstanceOf('Ctct\\Components\\Account\\VerifiedEmailAddress', $response[0]); $this->assertEquals("*****@*****.**", $response[0]->email_address); $this->assertEquals("CONFIRMED", $response[0]->status); }
public static function setUpBeforeClass() { self::$client = new Client(); $schedulesStream = Stream::factory(JsonLoader::getCampaignSchedulesJson()); $scheduleStream = Stream::factory(JsonLoader::getCampaignScheduleJson()); $testSendStream = Stream::factory(JsonLoader::getTestSendJson()); $mock = new Mock([new Response(200, array(), $schedulesStream), new Response(200, array(), $scheduleStream), new Response(201, array(), $scheduleStream), new Response(200, array(), $scheduleStream), new Response(204, array()), new Response(400, array()), new Response(200, array(), $testSendStream)]); self::$client->getEmitter()->attach($mock); }
public function testGetAccessToken() { $curlResponse = CurlResponse::create(JsonLoader::getAccessTokenJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('post')->with()->will($this->returnValue($curlResponse)); $token = $this->ctctOAuth2->getAccessToken("fakeCode"); $this->assertEquals("v6574b42-a5bc-4574-a87f-5c9d1202e316", $token['access_token']); $this->assertEquals("308874923", $token['expires_in']); $this->assertEquals("Bearer", $token['token_type']); }
public function testSendTest() { $curlResponse = CurlResponse::create(JsonLoader::getTestSendJson(), array('http_code' => 201)); $this->restClient->expects($this->once())->method('post')->with()->will($this->returnValue($curlResponse)); $testSend = $this->campaignScheduleService->sendTest('access_token', "9100367935463", new TestSend()); $this->assertInstanceOf('Ctct\\Components\\EmailMarketing\\TestSend', $testSend); $this->assertEquals("HTML", $testSend->format); $this->assertEquals("oh hai there", $testSend->personal_message); $this->assertEquals("*****@*****.**", $testSend->email_addresses[0]); }
public static function setUpBeforeClass() { self::$client = new Client(); $getFileStream = Stream::factory(JsonLoader::getLibraryFileJson()); $getFilesStream = Stream::factory(JsonLoader::getLibraryFilesJson()); $getFolderStream = Stream::factory(JsonLoader::getLibraryFolderJson()); $getFoldersStream = Stream::factory(JsonLoader::getLibraryFoldersJson()); $getFileUploadStream = Stream::factory(JsonLoader::getFileUploadStatusJson()); $mock = new Mock([new Response(200, array(), $getFileStream), new Response(200, array(), $getFilesStream), new Response(200, array(), $getFolderStream), new Response(200, array(), $getFoldersStream), new Response(201, array("Id" => 1)), new Response(200, array(), $getFileUploadStream)]); self::$client->getEmitter()->attach($mock); }
public static function setUpBeforeClass() { self::$client = new Client(); $activityStream = Stream::factory(JsonLoader::getActivity()); $activitiesStream = Stream::factory(JsonLoader::getActivities()); $clearListActivityStream = Stream::factory(JsonLoader::getClearListsActivity()); $exportActivityStream = Stream::factory(JsonLoader::getExportContactsActivity()); $removeContactsFromListStream = Stream::factory(JsonLoader::getRemoveContactsFromListsActivity()); $addContactsStream = Stream::factory(JsonLoader::getAddContactsActivity()); $mock = new Mock([new Response(200, array(), $activityStream), new Response(200, array(), $activitiesStream), new Response(201, array(), $clearListActivityStream), new Response(201, array(), $exportActivityStream), new Response(201, array(), $removeContactsFromListStream), new Response(201, array(), $addContactsStream)]); self::$client->getEmitter()->attach($mock); }
public function __construct() { require_once APPPATH . 'models/dto/page.php'; require_once APPPATH . 'libraries/JsonLoader.php'; $ci =& get_instance(); $ci->load->helper('url'); $ci->load->helper('directory'); $jsonLoader = new \JsonLoader(); $this->videos = array(); $fileStructure = directory_map(FCPATH . 'videos'); foreach ($fileStructure as $key => $structure) { if (is_array($structure)) { $metadata = $jsonLoader->Get(FCPATH . "videos/" . $key . "/metadata.json"); $page = new dto\Page(); $page->Name = $metadata->title; $page->Url = base_url() . $key; $page->Image = base_url() . "videos/" . $key . "/image.jpg"; $this->videos[] = $page; } } }
public static function setUpBeforeClass() { self::$client = new Client(); $getBouncesStream = Stream::factory(JsonLoader::getBounces()); $getClicksStream = Stream::factory(JsonLoader::getClicks()); $getForwardsStream = Stream::factory(JsonLoader::getForwards()); $getUnsubscribesStream = Stream::factory(JsonLoader::getOptOuts()); $getSendsStream = Stream::factory(JsonLoader::getSends()); $getOpensStream = Stream::factory(JsonLoader::getOpens()); $getSummaryStream = Stream::factory(JsonLoader::getSummary()); $mock = new Mock([new Response(200, array(), $getBouncesStream), new Response(200, array(), $getClicksStream), new Response(200, array(), $getForwardsStream), new Response(200, array(), $getUnsubscribesStream), new Response(200, array(), $getSendsStream), new Response(200, array(), $getOpensStream), new Response(200, array(), $getSummaryStream)]); self::$client->getEmitter()->attach($mock); }
public function testGetContactsFromList() { $curlResponse = CurlResponse::create(JsonLoader::getContactsJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('get')->with()->will($this->returnValue($curlResponse)); $response = $this->listService->getContactsFromList('access_token', 1); $this->assertInstanceOf("Ctct\\Components\\ResultSet", $response); $contact = $response->results[1]; $this->assertEquals(231, $contact->id); $this->assertEquals("ACTIVE", $contact->status); $this->assertEquals("", $contact->fax); $this->assertEquals("", $contact->prefix_name); $this->assertEquals("Jimmy", $contact->first_name); $this->assertEquals("", $contact->middle_name); $this->assertEquals("Roving", $contact->last_name); $this->assertEquals("Bear Tamer", $contact->job_title); $this->assertEquals("Animal Trainer Pro", $contact->company_name); $this->assertEquals("details", $contact->source_details); $this->assertEquals(false, $contact->confirmed); $this->assertEquals("", $contact->source); // custom fields $this->assertEquals("CustomField1", $contact->custom_fields[0]->name); $this->assertEquals("1", $contact->custom_fields[0]->value); //addresses $this->assertEquals("Suite 101", $contact->addresses[0]->line1); $this->assertEquals("line2", $contact->addresses[0]->line2); $this->assertEquals("line3", $contact->addresses[0]->line3); $this->assertEquals("Brookfield", $contact->addresses[0]->city); $this->assertEquals("PERSONAL", $contact->addresses[0]->address_type); $this->assertEquals("WI", $contact->addresses[0]->state_code); $this->assertEquals("us", $contact->addresses[0]->country_code); $this->assertEquals("53027", $contact->addresses[0]->postal_code); $this->assertEquals("", $contact->addresses[0]->sub_postal_code); //notes $this->assertEquals(0, count($contact->notes)); //lists $this->assertEquals(1, $contact->lists[0]->id); $this->assertEquals("ACTIVE", $contact->lists[0]->status); // EmailAddress $this->assertEquals("ACTIVE", $contact->email_addresses[0]->status); $this->assertEquals("NO_CONFIRMATION_REQUIRED", $contact->email_addresses[0]->confirm_status); $this->assertEquals("ACTION_BY_OWNER", $contact->email_addresses[0]->opt_in_source); $this->assertEquals("2012-06-22T10:29:09.976Z", $contact->email_addresses[0]->opt_in_date); $this->assertEquals("", $contact->email_addresses[0]->opt_out_date); $this->assertEquals("*****@*****.**", $contact->email_addresses[0]->email_address); }
public function testGetAccountInfo() { $curlResponse = CurlResponse::create(JsonLoader::getAccountInfoJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('get')->with()->will($this->returnValue($curlResponse)); $response = $this->accountService->getAccountInfo("accessToken"); $this->assertInstanceOf('Ctct\\Components\\Account\\AccountInfo', $response); $this->assertEquals("http://www.example.com", $response->website); $this->assertEquals("My Company", $response->organization_name); $this->assertEquals("http://www.example.com", $response->website); $this->assertEquals("My Company", $response->organization_name); $this->assertEquals("US/Eastern", $response->time_zone); $this->assertEquals("Mary Jane", $response->first_name); $this->assertEquals("Doe", $response->last_name); $this->assertEquals("*****@*****.**", $response->email); $this->assertEquals("5555555555", $response->phone); $this->assertEquals("https://ih.constantcontact.com/fs137/1100371573368/img/90.jpg", $response->company_logo); $this->assertEquals("US", $response->country_code); $this->assertEquals("MA", $response->state_code); }
public function testAddCreateContactsActivityFromFile() { $curlResponse = CurlResponse::create(JsonLoader::getAddContactsActivity(), array('http_code' => 201)); $this->restClient->expects($this->once())->method('post')->with()->will($this->returnValue($curlResponse)); $activity = $this->activityService->createAddContactsActivityFromFile("access_token", 'contacts.txt', JsonLoader::getContactsTextContents(), '7'); $this->assertInstanceOf('Ctct\\Components\\Activities\\Activity', $activity); $this->assertEquals("a07e1il69qzhdby44ro", $activity->id); $this->assertEquals("ADD_CONTACTS", $activity->type); $this->assertEquals(0, $activity->error_count); $this->assertEquals(1, $activity->contact_count); }
public function testGetSummary() { $curlResponse = CurlResponse::create(JsonLoader::getSummary(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('get')->with()->will($this->returnValue($curlResponse)); $summary = $this->campaignTrackingService->getSummary('access_token', 1100394165290); $this->assertInstanceOf('Ctct\\Components\\Tracking\\TrackingSummary', $summary); $this->assertEquals(15, $summary->sends); $this->assertEquals(10, $summary->opens); $this->assertEquals(10, $summary->clicks); $this->assertEquals(3, $summary->forwards); $this->assertEquals(2, $summary->unsubscribes); $this->assertEquals(18, $summary->bounces); }
/** * bad format. php5.4 won't support syntax error ! * * @covers Phossa\Config\Loader\JsonLoader::load() * @expectedException Phossa\Config\Exception\LogicException */ public function testLoad3() { $this->assertEquals(['test' => 'json'], JsonLoader::load(__DIR__ . '/conf/config_bad.json')); }
/** * Test loading a dir */ public function testLoadDir() { $data = (object) ['grp3' => ['one', 'two', 'three']]; $result = $this->loader->load(CONFIGTEST_SUPPORT_PATH . '/test-any'); $this->assertEquals($data, $result); }
public function testUpdateContact() { $curlResponse = CurlResponse::create(JsonLoader::getContactJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('put')->with()->will($this->returnValue($curlResponse)); $contact = $this->contactService->updateContact('access_token', new Contact(), array()); $this->assertInstanceOf("Ctct\\Components\\Contacts\\Contact", $contact); $this->assertEquals(238, $contact->id); $this->assertEquals("ACTIVE", $contact->status); $this->assertEquals("555-1212", $contact->fax); $this->assertEquals("Mr.", $contact->prefix_name); $this->assertEquals("John", $contact->first_name); $this->assertEquals("S", $contact->middle_name); $this->assertEquals("Smith", $contact->last_name); $this->assertEquals("Software Engineer", $contact->job_title); $this->assertEquals("Constant Contact", $contact->company_name); $this->assertEquals("555-1212", $contact->home_phone); $this->assertEquals("555-1213", $contact->work_phone); $this->assertEquals("555-1214", $contact->cell_phone); $this->assertEquals("69f9d72b-0a5e-479d-b844-722b1da9595f", $contact->source_details); $this->assertEquals(false, $contact->confirmed); $this->assertEquals("API", $contact->source); // custom fields $this->assertInstanceOf("Ctct\\Components\\Contacts\\CustomField", $contact->custom_fields[0]); $this->assertEquals("CustomField1", $contact->custom_fields[0]->name); $this->assertEquals("3/28/2011 11:09 AM EDT", $contact->custom_fields[0]->value); $this->assertEquals("CustomField2", $contact->custom_fields[1]->name); $this->assertEquals("Site owner", $contact->custom_fields[1]->value); //addresses $this->assertInstanceOf("Ctct\\Components\\Contacts\\Address", $contact->addresses[0]); $this->assertEquals("1601 Trapelo Rd", $contact->addresses[0]->line1); $this->assertEquals("Suite 329", $contact->addresses[0]->line2); $this->assertEquals("Line 3", $contact->addresses[0]->line3); $this->assertEquals("Waltham", $contact->addresses[0]->city); $this->assertEquals("PERSONAL", $contact->addresses[0]->address_type); $this->assertEquals("MA", $contact->addresses[0]->state_code); $this->assertEquals("us", $contact->addresses[0]->country_code); $this->assertEquals("01720", $contact->addresses[0]->postal_code); $this->assertEquals("7885", $contact->addresses[0]->sub_postal_code); //notes $this->assertInstanceOf("Ctct\\Components\\Contacts\\Note", $contact->notes[0]); $this->assertEquals(1, $contact->notes[0]->id); $this->assertEquals("Here are some cool notes to add", $contact->notes[0]->note); $this->assertEquals("2012-12-03T17:09:22.702Z", $contact->notes[0]->created_date); //lists $this->assertInstanceOf("Ctct\\Components\\Contacts\\ContactList", $contact->lists[0]); $this->assertEquals(9, $contact->lists[0]->id); $this->assertEquals("ACTIVE", $contact->lists[0]->status); // EmailAddress $this->assertInstanceOf("Ctct\\Components\\Contacts\\EmailAddress", $contact->email_addresses[0]); $this->assertEquals("ACTIVE", $contact->email_addresses[0]->status); $this->assertEquals("NO_CONFIRMATION_REQUIRED", $contact->email_addresses[0]->confirm_status); $this->assertEquals("ACTION_BY_VISITOR", $contact->email_addresses[0]->opt_in_source); $this->assertEquals("2012-09-17T14:40:41.271Z", $contact->email_addresses[0]->opt_in_date); $this->assertEquals("2012-03-29T14:59:25.427Z", $contact->email_addresses[0]->opt_out_date); $this->assertEquals("*****@*****.**", $contact->email_addresses[0]->email_address); }
/** * Clear the specified collection and populates it with the $json * * $json should be a JSON encoded array of documents * * @param string $collectionName * @param string $json * @return boolean */ public function loadJsonStringDatasetIntoCollection($collectionName, $json) { $collection = $this->getDatabase()->selectCollection($collectionName); $loader = new JsonLoader($collection); return $loader->loadJsonFromString($json); }
public function testUpdateCampaign() { $curlResponse = CurlResponse::create(JsonLoader::getCampaignJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('put')->with()->will($this->returnValue($curlResponse)); $campaign = $this->emailMarketingService->updateCampaign('access_token', new Campaign()); $this->assertEquals("1100394165290", $campaign->id); $this->assertEquals("CampaignName-05965ddb-12d2-43e5-b8f3-0c22ca487c3a", $campaign->name); $this->assertEquals("CampaignSubject", $campaign->subject); $this->assertEquals("SENT", $campaign->status); $this->assertEquals("From WSPI", $campaign->from_name); $this->assertEquals("*****@*****.**", $campaign->from_email); $this->assertEquals("*****@*****.**", $campaign->reply_to_email); $this->assertEquals("CUSTOM", $campaign->template_type); $this->assertEquals("2012-12-06T18:06:05.255Z", $campaign->created_date); $this->assertEquals("2012-12-06T18:06:40.342Z", $campaign->last_run_date); $this->assertEquals(false, $campaign->is_permission_reminder_enabled); $this->assertEquals("", $campaign->permission_reminder_text); $this->assertEquals(false, $campaign->is_view_as_webpage_enabled); $this->assertEquals("Having trouble viewing this email?", $campaign->view_as_web_page_text); $this->assertEquals("Click Here", $campaign->view_as_web_page_link_text); $this->assertEquals("Hi", $campaign->greeting_salutations); $this->assertEquals("FIRST_NAME", $campaign->greeting_name); $this->assertEquals("", $campaign->greeting_string); $this->assertEquals("<html><body>Hi <a href=\"http://www.constantcontact.com\">Visit ConstantContact.com!</a> </body></html>", $campaign->email_content); $this->assertEquals("HTML", $campaign->email_content_format); $this->assertEquals("", $campaign->style_sheet); $this->assertEquals("<text>Something to test</text>", $campaign->text_content); // message footer $this->assertEquals("Waltham", $campaign->message_footer->city); $this->assertEquals("MA", $campaign->message_footer->state); $this->assertEquals("US", $campaign->message_footer->country); $this->assertEquals("WSPIOrgName", $campaign->message_footer->organization_name); $this->assertEquals("1601 Trapelo RD", $campaign->message_footer->address_line_1); $this->assertEquals("suite 2", $campaign->message_footer->address_line_2); $this->assertEquals("box 4", $campaign->message_footer->address_line_3); $this->assertEquals("", $campaign->message_footer->international_state); $this->assertEquals("02451", $campaign->message_footer->postal_code); $this->assertEquals(true, $campaign->message_footer->include_forward_email); $this->assertEquals("WSPIForwardThisEmail", $campaign->message_footer->forward_email_link_text); $this->assertEquals(true, $campaign->message_footer->include_subscribe_link); $this->assertEquals("WSPISubscribeLinkText", $campaign->message_footer->subscribe_link_text); // tracking summary $this->assertEquals(15, $campaign->tracking_summary->sends); $this->assertEquals(10, $campaign->tracking_summary->opens); $this->assertEquals(10, $campaign->tracking_summary->clicks); $this->assertEquals(3, $campaign->tracking_summary->forwards); $this->assertEquals(2, $campaign->tracking_summary->unsubscribes); $this->assertEquals(18, $campaign->tracking_summary->bounces); // sent to contact lists $this->assertEquals(1, count($campaign->sent_to_contact_lists)); $this->assertEquals(3, $campaign->sent_to_contact_lists[0]->id); //click through details $this->assertEquals("http://www.constantcontact.com", $campaign->click_through_details[0]->url); $this->assertEquals("1100394163874", $campaign->click_through_details[0]->url_uid); $this->assertEquals(10, $campaign->click_through_details[0]->click_count); }