示例#1
0
 public function array_of_books_definition_using_compact_form_and_attributes()
 {
     $address = new XmlString('<books><book author="Test">Book #1</book><book>Book #2</book></books>');
     $this->assertEquals([new Book('Book #1', new Author('Test')), new Book('Book #2')], $address->next(new Enclosing('/'))->next(new ArrayOf(new CreationOf('util.address.unittest.Book', ['.' => function ($iteration) {
         $this->name = $iteration->next();
     }, '@author' => function ($iteration) {
         $this->author = new Author($iteration->next());
     }]))));
 }
示例#2
0
 public function next_with_definition()
 {
     $address = new XmlString('<doc><nested>Test</nested></doc>');
     $value = $address->next(new Enclosing('/'))->next(newinstance(Definition::class, [], ['create' => function ($iteration) {
         return [$iteration->path() => $iteration->next()];
     }]));
     $this->assertEquals(['//nested' => 'Test'], $value);
 }
示例#3
0
 public function by_definition($xml)
 {
     $address = new XmlString($xml);
     $this->assertEquals(new Book('Name', new Author('Test')), $address->next(new BookDefinition()));
 }