我正在使用流星0.6.4.
Meteor.methods({
random: function(top){
var random = Math.floor((Math.random()*(top+1)));
return random;
}
});
Run Code Online (Sandbox Code Playgroud)
每当我执行时它返回undefined
Meteor.call('random', 10);
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以超越这个?
$_GET在Laravel中是否有更好的方式来访问而不是变量本身,还是它?
我需要API的多个参数 /users?q=keyword&order=desc&limit=5
是否有更清洁,更安全和Laravel-ish方式来访问$ _GET值?
谢谢.
我想得到对象的实际返回值而不是可链接对象.
class Foo
{
public $attribute = 'data';
}
class FooSpec extends ObjectBehavior
{
public function it_is_a_test()
{
$attribute = $this->attribute; // I want to get 'data'
}
}
Run Code Online (Sandbox Code Playgroud)
这有什么办法吗?
谢谢.
在我sever/publish.js,我有这样的事情:
Questions = new Meteor.Collection("questions");
Meteor.publish("questions", function(){
return Questions.find();
});
Run Code Online (Sandbox Code Playgroud)
在我client/app.js做这样的事情时:
Questions = new Meteor.Collection("questions");
var questionHandle = Meteor.subscribe("questions");
Meteor.methods({
post: function(title){
Questions.insert({title: title});
}
});
$('.save').on('click', function(){
var title = $('input[name="title"]').val();
Meteor.call('post', title);
});
Run Code Online (Sandbox Code Playgroud)
它不起作用!但是,如果我把代码放在自身之外,服务器数据会更新.
Questions = new Meteor.Collection("questions");
var questionHandle = Meteor.subscribe("questions");
$('.save').on('click', function(){
var title = $('input[name="title"]').val();
Questions.insert({title: title});
});
Run Code Online (Sandbox Code Playgroud)
这是一个错误还是我错过了什么?
我知道截图可以通过扩展来实现,PHPUnit_Extensions_Selenium2TestCase但是现在,我正在使用Facebook的php-webdriver所以我只是延伸PHPUnit_Framework_TestCase
无论如何,只有驱动程序而不是扩展扩展名才能截取屏幕截图?
谢谢.
所以我从PHPUnit和Selenium 2 开始
public function testHasALoginForm()
{
$this->url('/login');
$username = $this->byName('username');
$password = $this->byName('password');
$this->assertEquals('', $username->value());
$this->assertEquals('', $password->value());
}
Run Code Online (Sandbox Code Playgroud)
这只发生在我value()从元素调用方法时,我最终得到:
1) test\view\LoginTest::testHasALoginForm
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: GET /session/fdcf0669-1d42-4a35-8e7a-29dec4a0f1e4/element/0/value
Build info: version: '2.42.1', revision: '68b415a', time: '2014-05-29 16:16:49'
System info: host: 'Something.local', ip: '192.168.1.108', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.3', java.version: '1.8.0_05'
Driver info: driver.version: unknown
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?