/** * test status can't be set to something weird. */ public function testInvalidStatus() { /** @var Endpoint $instance */ $instance = FactoryMuffin::instance('WebservicesNl\\Common\\Endpoint\\Endpoint', ['status' => Endpoint::STATUS_DISABLED]); $instance->setStatus('fake'); self::assertEquals(Endpoint::STATUS_DISABLED, $instance->getStatus()); }
public function setUp() { $this->logger = new Logger(__CLASS__); $this->testHandler = new TestHandler(); $streamHandler = new StreamHandler('/tmp/test.log', LogLevel::INFO); $this->logger->setHandlers([$streamHandler, $this->testHandler]); /** @var SoapSettings $settings */ $this->settings = FactoryMuffin::instance('WebservicesNl\\Protocol\\Soap\\Client\\SoapSettings'); $this->manager = new Manager(); $this->manager->createEndpoint('https://ws1.webservices.nl/soap_doclit'); }
/** * */ public function testConfigArrayIsBorked() { /** @var \WebservicesNl\Platform\Webservices\PlatformConfig $platformConfig */ $platformConfig = FactoryMuffin::instance('\\WebservicesNl\\Platform\\Webservices\\PlatformConfig', ['userName' => function () { return null; }]); /** @var \WebservicesNl\Protocol\Soap\Config\Platform\Webservices\Config $soapConfig */ $soapConfig = WebservicesConfig::configure($platformConfig); $resultArray = $soapConfig->toArray(); static::assertArrayNotHasKey('username', $resultArray); static::assertNull($soapConfig->getUserName()); static::assertCount(7, $resultArray); }
public function testCanHaveMembers() { $group = FactoryMuffin::create('DMA\\Friends\\Models\\UserGroup'); // Create member instances $member1 = FactoryMuffin::instance('RainLab\\User\\Models\\User'); $member2 = FactoryMuffin::instance('RainLab\\User\\Models\\User'); // Add members to the group and save them into the DB $group->users()->save($member1); $group->users()->save($member2); // Validate if the members are the same $this->assertEquals($group->users[0]->getKey(), $member1->getKey()); $this->assertEquals($group->users[1]->getKey(), $member2->getKey()); // Check if group validates all rules when saving $this->assertTrue($group->save()); }
/** * Create an instance of the model. * * This model will be automatically saved to the database if the model we * are generating it for has been saved (the create function was used). * * @param string $model Model class name. * * @return object */ protected function factory($model) { if (FactoryMuffin::isPendingOrSaved($this->object)) { return FactoryMuffin::create($model); } return FactoryMuffin::instance($model); }
/** * @throws \WebservicesNl\Common\Exception\Client\InputException * @throws \WebservicesNl\Common\Exception\Server\NoServerAvailableException * @throws InputException */ public function testEnableEndpointInErrorWithForce() { $manager = new Manager(); /** @var Endpoint $active */ $active = FactoryMuffin::instance('WebservicesNl\\Common\\Endpoint\\Endpoint', ['status' => Endpoint::STATUS_ACTIVE]); /** @var Endpoint $shortTimeout */ $shortTimeout = FactoryMuffin::instance('WebservicesNl\\Common\\Endpoint\\Endpoint', ['status' => Endpoint::STATUS_ERROR, 'lastConnected' => function () { $time = new \DateTime(); $time->modify('-30 minutes'); return $time; }]); $manager->addEndpoint($active); $manager->addEndpoint($shortTimeout); // try to enable endpoint in Error with a short time out $result = $manager->activateEndpoint($shortTimeout, true); static::assertEquals($manager->getActiveEndpoint(), $result); }