I cant find example with PHPunit. I don't know what function i suppose to use. there are a lot examples for java but i cant find nothing for PHPUnit.
I opened the http://localhost:4444/wd/hub/static/resource/hub.html
and in capabilities there aren't settings for a proxy.
When i used the function setDesiredCapabilities the selenium always opened IE. Below are my "code"
class testtest extends PHPUnit_Extensions_Selenium2TestCase {
protected function setUp()
{
$capabilities=array('browser' => 'firefox');
$this->setDesiredCapabilities($capabilities);
$this->setBrowserUrl('http://www.test.com/');
}
public function testvvatg()
{
$this->url('http://www.test.com');
$url=$this->title();
$this->assertEquals('asdf', $url);
}
}
Please help thanks
While this topic is old, I found it while googling for a solution to the problem, so I figured I'd contribute.
Reading the source of PHPUnit Selenium2TestCase, you can see a link to the format that setDesiredCapabilities requires. In particular, you'd want the Proxy JSON Object format.
For example:
$this->setDesiredCapabilities(array(
"proxy" => array(
"proxyType" => "manual",
"httpProxy" => "proxyhost.com:1337",
"noProxy" => "dontproxy.me/please" //This one is undocumented. I'm not sure how to specify more than one
)
));
Related
I'm trying to export some data using fromview interface.
public function view(): View
{
$this->view = "admin.reports.price_summary_export";
$this->data = PriceReportController::getData($this->data, $this->filters, $this->rj);
return view($this->view, ["xls" => true, "data" => $this->data, "filters" => $this->filters]);
}
When $this->data is large the code will always timeout at CloseSheet. Is there any way to avoid this error?
Im a beginner in laravel so i dont understand much. So far i've tried extending the timeout to 10 minutes and it can run properly, but i dont like this solution. Im trying to find another solution for this issue
Currently i am rewriting a cakephp2.3 application in cakephp4+.
in my controller (just for test reasons) I wrote this five lines.
$session = $this->request->getSession();
$session->write([
'TDSPeople.active' => $this->request->getData('active'),
'TDSPeople.filter' => $this->request->getData('filter')
]);
debug($session);
my debug output only shows:
object(Cake\Http\Session) id:0 {
protected _engine => null
protected _started => true
protected _lifetime => (int) 1440
protected _isCLI => false
}
what went wrong?
Do i have to declare that I want to use the session component or is it a configuration problem related to working on my development server without SSL.
Any help appreciated
thx
Thanks to the hidden hint of ndm´s comment the problem ist solved the data is where it should be and all is fine. sorry for the confusion. I´ve tried to access the keys in $session->read (obviously) directly and there it appeared.
I've been looking for the answer for two days and still nothing. I've followed several tutorials where nothing more than just a few config settings are required, but my Laravel 4 app still doesn't want to send an e-mail. It always throws the same Exception and nobody seems to have the answer. It seems that I've tried everything but the working one.
Route::get('/sendemail', function() {
$data['user'] = 'Test User';
Mail::send('email.test', $data, function($m) {
$m->to('myemail#example.com')->subject('Email test');
});
});
But when I'm in the specified route, it always throws the same error:
Argument 1 passed to Swift_Transport_EsmtpTransport::__construct()
must implement interface Swift_Transport_IoBuffer, none given
The config is ok and even changing the driver from 'smtp' to 'mail' in config/mail.php throws also Exception.
Argument 1 passed to Swift_Transport_MailTransport::__construct() must be an instance of Swift_Transport_MailInvoker, none given
I'm stuck in here and I don't know that to do. My composer is up to date and PHP version is 5.4.4.
Any advice will be much appreciated.
Thank you.
You have probably found an answer by now.
But I think you need a second argument for the to.
Try:
$data = array('user' => $user);
Mail::send('email.test', $data, function($message) use ($user)
{
$message->to($user->email, $user->name)->subject('Email Test');
});
I cannot seem to register a custom view helper in zend Framework 2.02 I tried all solutions posted here and anything I can think I should do but I keep getting this error:
Fatal error: Class 'ModuleName\view\Helper\mylinkhelper' not found in C:\wamp\vhosts\projectName\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php on line 177
And here's how my module.config.php looks like:
return array{
'controllers'=>array(
....
),
'view_manager' => array(
'template_path_stack' => array(
'ModuleName' => __DIR__ . '/../view',
),
),
'view_helpers' => array(
'invokables' => array(
'mylink' => 'ModuleName\view\Helper\mylinkhelper',
),
),
};
in my view file, I have:
echo $this->mylink($someparameter);
I appreciate any feedback on this. I don't really know what else to do here.
<?php
// ./module/Application/src/Application/View/Helper/AbsoluteUrl.php
namespace Application\View\Helper;
use Zend\Http\Request;
use Zend\View\Helper\AbstractHelper;
class AbsoluteUrl extends AbstractHelper
{
protected $request;
public function __construct(Request $request)
{
$this->request = $request;
}
public function __invoke()
{
return $this->request->getUri()->normalize();
}
}
You’ll notice that this particular helper has a dependency — a Zend\Http\Request object. To inject this, we’ll need to set up a factory with the initialization logic for our view helper:
<?php
// ./module/Application/Module.php
namespace Application;
use Application\View\Helper\AbsoluteUrl;
class Module
{
public function getViewHelperConfig()
{
return array(
'factories' => array(
// the array key here is the name you will call the view helper by in your view scripts
'absoluteUrl' => function($sm) {
$locator = $sm->getServiceLocator(); // $sm is the view helper manager, so we need to fetch the main service manager
return new AbsoluteUrl($locator->get('Request'));
},
),
);
}
// If copy/pasting this example, you'll also need the getAutoloaderConfig() method; I've omitted it for the sake of brevity.
}
That’s it! Now you can call your helper in your view scripts:
The full URL to the current page is: <?php echo $this->absoluteUrl(); ?>
thanks to evan to create this tutorial
It looks like the View Helper is correctly added to the ServiceManager since invoking mylink() is trying to create ModuleName\view\Helper\mylinkhelper.
I'd make sure the class is creatable with new College\view\Helper\mylinkhelper(); from a controller, this is likely to throw up some clues. Also check the filename and classname are correct.
Your approach is correct, but there might be two things which cause you this trouble:
You talk about a top level namespace ModuleName, but in your example configuration you have the top level namespace College. When you have a ModuleName namespace and you try to load College, that obviously does not work
Your view helper cannot be autoloaded. Are you sure the class name is correct (MyLinkHelper), the namespace is correct (College\View\Helper, see also above) and the file name is correct (MyLinkHelper.php). And have you enabled class-name autoloading for this module in your module class?
A third option might be the lower case "view" and "mylinkhelper" as usually you would write College\View\Helper\MyLinkHelper with a capital V, M, L and H. But since you are on Windows that should not matter afaik. I know for Linux you must be aware of case sensitiveness of class names.
The problem is that the class file is not being loaded. Its supposed to be included in autoload_classmap.php.
<?php
return array(
'{module}\View\Helper\{helper}' => __DIR__ . '\View\Helper\{helper}.php',
);
?>
I ran in the same issue and this page helped me.
As I'm new to ZF, i don't know if there is another way to add the paths in autoload_classmap, i think probably there is, but i just edited the file manually.
Got the same problem, found out by myself that view helper file was not included. while putting it into controller for testing it worked
e.g.: require_once('module/Pages/view/Helper/RenderNav.php');
why it has not been autoloaded ?
I want to convert a URL which is of the format
path/to/my/app/Controller_action/id/2
to
path/to/my/app/Controller_action/id/User_corresponding_to_id_2
I have already seen this tutorial from Yii, but it isnt helping me with anything. Can anyone help me with this?
EDIT: I would also like to know if this thing is even possible in the POST scenario, ie I will only have path/to/my/app/Controller_action in the URL.
Add a getUrl method in your User model
public function getUrl()
{
return Yii::app()->createUrl('controller/action', array(
'id'=>$this->id,
'username'=>$this->username,
));
}
Add the following rule urlManager component in config/main.php
'controller/action/<username:.*?>/<id: \d+>'=>'controller/action'
And use the models url virtual attribute everywhere
dInGd0nG is on the correct track, but if I understand correctly you wish to do actions based on the actual username instead of the ID as well right?
It's not that hard in Yii. I'm assuming here for simplicity the controller is user and the action is view.
Your User controller:
public function actionView($id)
{
if (is_numeric($id))
$oUser = User::model()->findByPk($id);
else
// Luckily Yii does parameter binding, wouldn't be such a good idea otherwise :)
$oUser = User::model()->findByAttributes(array('username' => $id));
...
}
Your urlManager config:
'user/view/<id: \w+>' => 'user/view',
Or more generally:
'user/<action: \w+>/<id: \w+> => 'user/<action>',
To generate a user url in a view:
$this->createUrl('user/view', array('id' => $oUser->username));