/** * @depends testConfiglessConstructor */ public function testConstructor() { $connection = new Connection('https://*****:*****@test.freshdesk.com'); $contact = new Contact($connection); $sectionGetters = $this->configlessProvider(); $sectionGetters = array_pop($sectionGetters); foreach ($sectionGetters as $section) { $section = Rest::GetSection($section); if ($section instanceof Contact) { $this->assertEquals($contact, $section); } $configs = $this->getConnection($section, $contact); $this->assertEquals($configs['expected'], $configs['instance']); $this->assertEquals($configs['instance']->getBaseUrl(), $connection->getBaseUrl()); $this->assertEquals($configs['expected']->getBaseUrl(), $connection->getBaseUrl()); $this->assertEquals($configs['expected']->getDomain(), $connection->getDomain()); $this->assertEquals($configs['instance']->getDomain(), $connection->getDomain()); $this->assertEquals($configs['instance']->getScheme(), $connection->getScheme()); $this->assertEquals($configs['expected']->getScheme(), $connection->getScheme()); $this->assertEquals($configs['instance']->getUserName(), $connection->getUserName()); $this->assertEquals($configs['expected']->getUserName(), $connection->getUserName()); $this->assertEquals($configs['expected']->getPassword(), $connection->getPassword()); $this->assertEquals($configs['instance']->getPassword(), $connection->getPassword()); } }
/** * @dataProvider setUrlStringProvider */ public function testUrlSetterError($url, $success = true) { if ($success === false) { $this->setExpectedException('RuntimeException'); $this->instance->setByUrl($url); } else { $this->instance->setByUrl($url); $parsed = parse_url($url); $this->assertEquals($parsed['pass'], $this->instance->getPassword(), sprintf('%s expected to be equal to %s', $this->instance->getPassword(), $parsed['pass'])); $this->assertEquals($parsed['scheme'] . '://', $this->instance->getScheme(), sprintf('%s expected to be equal to %s', $this->instance->getScheme(), $parsed['scheme'] . '://')); $this->assertEquals($parsed['host'], $this->instance->getDomain(), sprintf('%s expected to be equal to %s', $this->instance->getDomain(), $parsed['host'])); $this->assertEquals($parsed['user'], $this->instance->getUserName(), sprintf('%s expected to be equal to %s', $this->instance->getUserName(), $parsed['user'])); } }