public function testCommunicationEmailProviderCantBeAProcessor() { $this->assertCount(0, CommunicationItem::find(), "CommunicationItem count was not 0"); $this->assertCount(0, Communication::find(), "Communication count was not 0"); $email = new SimpleEmail(); $email->setSubject("A fine day in the park"); $email->addRecipientByEmail("*****@*****.**", "Joe Bloggs"); $email->setHtml("<html><head>Test Head</head><body>Test Body</body></html>"); $email->setText("Test Text Body"); CommunicationProcessor::setProviderClassName(EmailProvider::class, CommunicationEmailProvider::class); try { EmailProvider::setProviderClassName(CommunicationEmailProvider::class); EmailProvider::getProvider()->send($email); $this->fail('Email should not sent due to invalid Communication Provider being set'); } catch (InvalidProviderException $exception) { } }
protected function initialise() { require_once __DIR__ . '/../../unit/UrlHandlers/UrlHandlerTestUnitTest.php'; parent::initialise(); $login = new ValidateLoginUrlHandler(UnitTestingLoginProvider::singleton(), "/login/index"); $login->SetPriority(20); $this->addUrlHandlers(["/cant/be/here" => $login]); $login = new ValidateLoginUrlHandler(UnitTestingLoginProvider::singleton(), "/defo/not/here/login/index/", ["login/index/" => new ClassMappedUrlHandler(SimpleContent::class)]); $login->setPriority(20); $this->addUrlHandlers(["/defo/not/here/" => $login]); $this->addUrlHandlers([new UnitTestComputedUrlHandler()]); $this->addUrlHandlers(["/" => new ClassMappedUrlHandler(SimpleContent::class, ["nmh/" => new NamespaceMappedUrlHandler('Rhubarb\\Crown\\Tests\\Fixtures\\UrlHandlers\\NamespaceMappedHandlerTests'), "simple/" => new ClassMappedUrlHandler(SimpleContent::class), "files/" => new StaticResourceUrlHandler(__DIR__ . "/../UrlHandlers/")])]); $this->addUrlHandlers("/priority-test/", new ValidateLoginUrlHandler(UnitTestingLoginProvider::singleton(), "/login/index")); $test = new NamespaceMappedUrlHandler('Rhubarb\\Leaf\\Presenters'); $test->setPriority(100); $this->addUrlHandlers("/priority-test/", $test); EmailProvider::setProviderClassName(UnitTestingEmailProvider::class); }